repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
flynn/flynn | appliance/mariadb/process.go | Restore | func (p *Process) Restore(r io.Reader) (*BackupInfo, error) {
if err := p.writeConfig(configData{}); err != nil {
return nil, err
}
if err := p.unpackXbstream(r); err != nil {
return nil, err
}
backupInfo, err := p.extractBackupInfo()
if err != nil {
return nil, err
}
if err := p.restoreApplyLog(); err !=... | go | func (p *Process) Restore(r io.Reader) (*BackupInfo, error) {
if err := p.writeConfig(configData{}); err != nil {
return nil, err
}
if err := p.unpackXbstream(r); err != nil {
return nil, err
}
backupInfo, err := p.extractBackupInfo()
if err != nil {
return nil, err
}
if err := p.restoreApplyLog(); err !=... | [
"func",
"(",
"p",
"*",
"Process",
")",
"Restore",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"BackupInfo",
",",
"error",
")",
"{",
"if",
"err",
":=",
"p",
".",
"writeConfig",
"(",
"configData",
"{",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"r... | // Restore restores the database from an xbstream backup. | [
"Restore",
"restores",
"the",
"database",
"from",
"an",
"xbstream",
"backup",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L341-L356 | train |
flynn/flynn | appliance/mariadb/process.go | DSN | func (p *Process) DSN() *DSN {
return &DSN{
Host: "127.0.0.1:" + p.Port,
User: "flynn",
Password: p.Password,
Timeout: p.OpTimeout,
}
} | go | func (p *Process) DSN() *DSN {
return &DSN{
Host: "127.0.0.1:" + p.Port,
User: "flynn",
Password: p.Password,
Timeout: p.OpTimeout,
}
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"DSN",
"(",
")",
"*",
"DSN",
"{",
"return",
"&",
"DSN",
"{",
"Host",
":",
"\"",
"\"",
"+",
"p",
".",
"Port",
",",
"User",
":",
"\"",
"\"",
",",
"Password",
":",
"p",
".",
"Password",
",",
"Timeout",
":",... | // DSN returns the data source name for connecting to the local process as the "flynn" user. | [
"DSN",
"returns",
"the",
"data",
"source",
"name",
"for",
"connecting",
"to",
"the",
"local",
"process",
"as",
"the",
"flynn",
"user",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L890-L897 | train |
flynn/flynn | appliance/mariadb/process.go | nodeXLogPosition | func (p *Process) nodeXLogPosition(dsn *DSN) (xlog.Position, error) {
db, err := sql.Open("mysql", dsn.String())
if err != nil {
return p.XLog().Zero(), err
}
defer db.Close()
var gtid string
if err := db.QueryRow(`SELECT @@gtid_current_pos`).Scan(>id); err != nil {
return p.XLog().Zero(), err
}
return x... | go | func (p *Process) nodeXLogPosition(dsn *DSN) (xlog.Position, error) {
db, err := sql.Open("mysql", dsn.String())
if err != nil {
return p.XLog().Zero(), err
}
defer db.Close()
var gtid string
if err := db.QueryRow(`SELECT @@gtid_current_pos`).Scan(>id); err != nil {
return p.XLog().Zero(), err
}
return x... | [
"func",
"(",
"p",
"*",
"Process",
")",
"nodeXLogPosition",
"(",
"dsn",
"*",
"DSN",
")",
"(",
"xlog",
".",
"Position",
",",
"error",
")",
"{",
"db",
",",
"err",
":=",
"sql",
".",
"Open",
"(",
"\"",
"\"",
",",
"dsn",
".",
"String",
"(",
")",
")",... | // XLogPosition returns the current XLogPosition of node specified by DSN. | [
"XLogPosition",
"returns",
"the",
"current",
"XLogPosition",
"of",
"node",
"specified",
"by",
"DSN",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L904-L917 | train |
flynn/flynn | appliance/mariadb/process.go | installDB | func (p *Process) installDB() error {
logger := p.Logger.New("fn", "installDB", "data_dir", p.DataDir)
logger.Debug("starting installDB")
// Ignore errors, since the db could be already initialized
p.runCmd(exec.Command(
filepath.Join(p.BinDir, "mysql_install_db"),
"--defaults-extra-file="+p.ConfigPath(),
))
... | go | func (p *Process) installDB() error {
logger := p.Logger.New("fn", "installDB", "data_dir", p.DataDir)
logger.Debug("starting installDB")
// Ignore errors, since the db could be already initialized
p.runCmd(exec.Command(
filepath.Join(p.BinDir, "mysql_install_db"),
"--defaults-extra-file="+p.ConfigPath(),
))
... | [
"func",
"(",
"p",
"*",
"Process",
")",
"installDB",
"(",
")",
"error",
"{",
"logger",
":=",
"p",
".",
"Logger",
".",
"New",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"p",
".",
"DataDir",
")",
"\n",
"logger",
".",
"Debug",
"(",
"... | // installDB initializes the data directory for a new database. | [
"installDB",
"initializes",
"the",
"data",
"directory",
"for",
"a",
"new",
"database",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L920-L931 | train |
flynn/flynn | appliance/mariadb/process.go | Close | func (r *backupReadCloser) Close() error {
defer r.stdout.Close()
if err := r.cmd.Wait(); err != nil {
return err
}
// Verify that innobackupex prints "completed OK!" at the end of STDERR.
if !strings.HasSuffix(strings.TrimSpace(r.stderr.String()), "completed OK!") {
r.stderr.WriteTo(os.Stderr)
return erro... | go | func (r *backupReadCloser) Close() error {
defer r.stdout.Close()
if err := r.cmd.Wait(); err != nil {
return err
}
// Verify that innobackupex prints "completed OK!" at the end of STDERR.
if !strings.HasSuffix(strings.TrimSpace(r.stderr.String()), "completed OK!") {
r.stderr.WriteTo(os.Stderr)
return erro... | [
"func",
"(",
"r",
"*",
"backupReadCloser",
")",
"Close",
"(",
")",
"error",
"{",
"defer",
"r",
".",
"stdout",
".",
"Close",
"(",
")",
"\n\n",
"if",
"err",
":=",
"r",
".",
"cmd",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"er... | // Close waits for the backup command to finish and verifies that the backup completed successfully. | [
"Close",
"waits",
"for",
"the",
"backup",
"command",
"to",
"finish",
"and",
"verifies",
"that",
"the",
"backup",
"completed",
"successfully",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L1002-L1016 | train |
flynn/flynn | appliance/mariadb/process.go | Read | func (r *backupReadCloser) Read(p []byte) (n int, err error) {
return r.stdout.Read(p)
} | go | func (r *backupReadCloser) Read(p []byte) (n int, err error) {
return r.stdout.Read(p)
} | [
"func",
"(",
"r",
"*",
"backupReadCloser",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"return",
"r",
".",
"stdout",
".",
"Read",
"(",
"p",
")",
"\n",
"}"
] | // Read reads n bytes of backup data into p. | [
"Read",
"reads",
"n",
"bytes",
"of",
"backup",
"data",
"into",
"p",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L1019-L1021 | train |
flynn/flynn | host/libcontainer_backend.go | discoverdDial | func (l *LibcontainerBackend) discoverdDial(network, addr string) (net.Conn, error) {
host, _, err := net.SplitHostPort(addr)
if err != nil {
return nil, err
}
if strings.HasSuffix(host, ".discoverd") {
// ensure discoverd is configured
<-l.discoverdConfigured
// lookup the service and pick a random address... | go | func (l *LibcontainerBackend) discoverdDial(network, addr string) (net.Conn, error) {
host, _, err := net.SplitHostPort(addr)
if err != nil {
return nil, err
}
if strings.HasSuffix(host, ".discoverd") {
// ensure discoverd is configured
<-l.discoverdConfigured
// lookup the service and pick a random address... | [
"func",
"(",
"l",
"*",
"LibcontainerBackend",
")",
"discoverdDial",
"(",
"network",
",",
"addr",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"host",
",",
"_",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"addr",
")",
"\n",
... | // discoverdDial is a discoverd aware dialer which resolves a discoverd host to
// an address using the configured discoverd client as the host is likely not
// using discoverd to resolve DNS queries | [
"discoverdDial",
"is",
"a",
"discoverd",
"aware",
"dialer",
"which",
"resolves",
"a",
"discoverd",
"host",
"to",
"an",
"address",
"using",
"the",
"configured",
"discoverd",
"client",
"as",
"the",
"host",
"is",
"likely",
"not",
"using",
"discoverd",
"to",
"reso... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/libcontainer_backend.go#L940-L959 | train |
flynn/flynn | router/data_store.go | NewPostgresDataStore | func NewPostgresDataStore(routeType string, pgx *pgx.ConnPool) *pgDataStore {
tableName := ""
switch routeType {
case routeTypeHTTP:
tableName = tableNameHTTP
case routeTypeTCP:
tableName = tableNameTCP
default:
panic(fmt.Sprintf("unknown routeType: %q", routeType))
}
return &pgDataStore{
pgx: pgx,... | go | func NewPostgresDataStore(routeType string, pgx *pgx.ConnPool) *pgDataStore {
tableName := ""
switch routeType {
case routeTypeHTTP:
tableName = tableNameHTTP
case routeTypeTCP:
tableName = tableNameTCP
default:
panic(fmt.Sprintf("unknown routeType: %q", routeType))
}
return &pgDataStore{
pgx: pgx,... | [
"func",
"NewPostgresDataStore",
"(",
"routeType",
"string",
",",
"pgx",
"*",
"pgx",
".",
"ConnPool",
")",
"*",
"pgDataStore",
"{",
"tableName",
":=",
"\"",
"\"",
"\n",
"switch",
"routeType",
"{",
"case",
"routeTypeHTTP",
":",
"tableName",
"=",
"tableNameHTTP",... | // NewPostgresDataStore returns a DataStore that stores route information in a
// Postgres database. It uses pg_notify and a listener connection to watch for
// route changes. | [
"NewPostgresDataStore",
"returns",
"a",
"DataStore",
"that",
"stores",
"route",
"information",
"in",
"a",
"Postgres",
"database",
".",
"It",
"uses",
"pg_notify",
"and",
"a",
"listener",
"connection",
"to",
"watch",
"for",
"route",
"changes",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/data_store.go#L69-L84 | train |
flynn/flynn | updater/updater.go | updateImageIDs | func updateImageIDs(env map[string]string) bool {
updated := false
for prefix, newID := range map[string]string{
"REDIS": redisImage.ID,
"SLUGBUILDER": slugBuilder.ID,
"SLUGRUNNER": slugRunner.ID,
} {
idKey := prefix + "_IMAGE_ID"
if id, ok := env[idKey]; ok && id != newID {
env[idKey] = newID
... | go | func updateImageIDs(env map[string]string) bool {
updated := false
for prefix, newID := range map[string]string{
"REDIS": redisImage.ID,
"SLUGBUILDER": slugBuilder.ID,
"SLUGRUNNER": slugRunner.ID,
} {
idKey := prefix + "_IMAGE_ID"
if id, ok := env[idKey]; ok && id != newID {
env[idKey] = newID
... | [
"func",
"updateImageIDs",
"(",
"env",
"map",
"[",
"string",
"]",
"string",
")",
"bool",
"{",
"updated",
":=",
"false",
"\n",
"for",
"prefix",
",",
"newID",
":=",
"range",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"redisImage",
".",
"... | // updateImageIDs updates REDIS_IMAGE_ID, SLUGBUILDER_IMAGE_ID and
// SLUGRUNNER_IMAGE_ID if they are set and have an old ID, and also
// replaces the legacy REDIS_IMAGE_URI, SLUGBUILDER_IMAGE_URI and
// SLUGRUNNER_IMAGE_URI | [
"updateImageIDs",
"updates",
"REDIS_IMAGE_ID",
"SLUGBUILDER_IMAGE_ID",
"and",
"SLUGRUNNER_IMAGE_ID",
"if",
"they",
"are",
"set",
"and",
"have",
"an",
"old",
"ID",
"and",
"also",
"replaces",
"the",
"legacy",
"REDIS_IMAGE_URI",
"SLUGBUILDER_IMAGE_URI",
"and",
"SLUGRUNNER_... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/updater/updater.go#L253-L274 | train |
flynn/flynn | appliance/postgresql/pgxlog/pgxlog.go | Increment | func (p PgXLog) Increment(pos xlog.Position, increment int) (xlog.Position, error) {
parts, err := parse(pos)
if err != nil {
return "", err
}
return makePosition(parts[0], parts[1]+increment), nil
} | go | func (p PgXLog) Increment(pos xlog.Position, increment int) (xlog.Position, error) {
parts, err := parse(pos)
if err != nil {
return "", err
}
return makePosition(parts[0], parts[1]+increment), nil
} | [
"func",
"(",
"p",
"PgXLog",
")",
"Increment",
"(",
"pos",
"xlog",
".",
"Position",
",",
"increment",
"int",
")",
"(",
"xlog",
".",
"Position",
",",
"error",
")",
"{",
"parts",
",",
"err",
":=",
"parse",
"(",
"pos",
")",
"\n",
"if",
"err",
"!=",
"... | // Increment increments an xlog position by the given number. | [
"Increment",
"increments",
"an",
"xlog",
"position",
"by",
"the",
"given",
"number",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/postgresql/pgxlog/pgxlog.go#L53-L59 | train |
flynn/flynn | appliance/postgresql/pgxlog/pgxlog.go | parse | func parse(xlog xlog.Position) (res [2]int, err error) {
parts := strings.SplitN(string(xlog), "/", 2)
if len(parts) != 2 {
err = fmt.Errorf("malformed xlog position %q", xlog)
return
}
res[0], err = parseHex(parts[0])
if err != nil {
return
}
res[1], err = parseHex(parts[1])
return
} | go | func parse(xlog xlog.Position) (res [2]int, err error) {
parts := strings.SplitN(string(xlog), "/", 2)
if len(parts) != 2 {
err = fmt.Errorf("malformed xlog position %q", xlog)
return
}
res[0], err = parseHex(parts[0])
if err != nil {
return
}
res[1], err = parseHex(parts[1])
return
} | [
"func",
"parse",
"(",
"xlog",
"xlog",
".",
"Position",
")",
"(",
"res",
"[",
"2",
"]",
"int",
",",
"err",
"error",
")",
"{",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"string",
"(",
"xlog",
")",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
... | // parse takes an xlog position emitted by postgres and returns an array of two
// integers representing the filepart and offset components of the xlog
// position. This is an internal representation that should not be exposed
// outside of this package. | [
"parse",
"takes",
"an",
"xlog",
"position",
"emitted",
"by",
"postgres",
"and",
"returns",
"an",
"array",
"of",
"two",
"integers",
"representing",
"the",
"filepart",
"and",
"offset",
"components",
"of",
"the",
"xlog",
"position",
".",
"This",
"is",
"an",
"in... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/postgresql/pgxlog/pgxlog.go#L86-L100 | train |
flynn/flynn | appliance/postgresql/pgxlog/pgxlog.go | makePosition | func makePosition(filepart int, offset int) xlog.Position {
return xlog.Position(fmt.Sprintf("%X/%08X", filepart, offset))
} | go | func makePosition(filepart int, offset int) xlog.Position {
return xlog.Position(fmt.Sprintf("%X/%08X", filepart, offset))
} | [
"func",
"makePosition",
"(",
"filepart",
"int",
",",
"offset",
"int",
")",
"xlog",
".",
"Position",
"{",
"return",
"xlog",
".",
"Position",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"filepart",
",",
"offset",
")",
")",
"\n",
"}"
] | // MakePosition constructs an xlog position string from a numeric file part and
// offset. | [
"MakePosition",
"constructs",
"an",
"xlog",
"position",
"string",
"from",
"a",
"numeric",
"file",
"part",
"and",
"offset",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/postgresql/pgxlog/pgxlog.go#L104-L106 | train |
flynn/flynn | host/logmux/sink.go | parseProcID | func parseProcID(procID []byte) (string, string) {
procTypeID := strings.SplitN(string(procID), ".", 2)
if len(procTypeID) == 2 {
return procTypeID[1], procTypeID[0]
}
return procTypeID[0], ""
} | go | func parseProcID(procID []byte) (string, string) {
procTypeID := strings.SplitN(string(procID), ".", 2)
if len(procTypeID) == 2 {
return procTypeID[1], procTypeID[0]
}
return procTypeID[0], ""
} | [
"func",
"parseProcID",
"(",
"procID",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"string",
")",
"{",
"procTypeID",
":=",
"strings",
".",
"SplitN",
"(",
"string",
"(",
"procID",
")",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"procTypeI... | // Parses JobID and ProcType from header ProcID field
// Always returns JobID, returns ProcType if available | [
"Parses",
"JobID",
"and",
"ProcType",
"from",
"header",
"ProcID",
"field",
"Always",
"returns",
"JobID",
"returns",
"ProcType",
"if",
"available"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/logmux/sink.go#L571-L577 | train |
flynn/flynn | pkg/sirenia/scale/scale.go | CheckScale | func CheckScale(app, controllerKey, procName string, logger log15.Logger) (bool, error) {
logger = logger.New("fn", "CheckScale")
// Connect to controller.
logger.Info("connecting to controller")
client, err := controller.NewClient("", controllerKey)
if err != nil {
logger.Error("controller client error", "err",... | go | func CheckScale(app, controllerKey, procName string, logger log15.Logger) (bool, error) {
logger = logger.New("fn", "CheckScale")
// Connect to controller.
logger.Info("connecting to controller")
client, err := controller.NewClient("", controllerKey)
if err != nil {
logger.Error("controller client error", "err",... | [
"func",
"CheckScale",
"(",
"app",
",",
"controllerKey",
",",
"procName",
"string",
",",
"logger",
"log15",
".",
"Logger",
")",
"(",
"bool",
",",
"error",
")",
"{",
"logger",
"=",
"logger",
".",
"New",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"/... | // CheckScale examines sirenia cluster formation to check if cluster
// has been scaled up yet.
// Returns true if scaled, false if not. | [
"CheckScale",
"examines",
"sirenia",
"cluster",
"formation",
"to",
"check",
"if",
"cluster",
"has",
"been",
"scaled",
"up",
"yet",
".",
"Returns",
"true",
"if",
"scaled",
"false",
"if",
"not",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sirenia/scale/scale.go#L103-L142 | train |
RichardKnop/machinery | v1/worker.go | Launch | func (worker *Worker) Launch() error {
errorsChan := make(chan error)
worker.LaunchAsync(errorsChan)
return <-errorsChan
} | go | func (worker *Worker) Launch() error {
errorsChan := make(chan error)
worker.LaunchAsync(errorsChan)
return <-errorsChan
} | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"Launch",
"(",
")",
"error",
"{",
"errorsChan",
":=",
"make",
"(",
"chan",
"error",
")",
"\n\n",
"worker",
".",
"LaunchAsync",
"(",
"errorsChan",
")",
"\n\n",
"return",
"<-",
"errorsChan",
"\n",
"}"
] | // Launch starts a new worker process. The worker subscribes
// to the default queue and processes incoming registered tasks | [
"Launch",
"starts",
"a",
"new",
"worker",
"process",
".",
"The",
"worker",
"subscribes",
"to",
"the",
"default",
"queue",
"and",
"processes",
"incoming",
"registered",
"tasks"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L32-L38 | train |
RichardKnop/machinery | v1/worker.go | LaunchAsync | func (worker *Worker) LaunchAsync(errorsChan chan<- error) {
cnf := worker.server.GetConfig()
broker := worker.server.GetBroker()
// Log some useful information about worker configuration
log.INFO.Printf("Launching a worker with the following settings:")
log.INFO.Printf("- Broker: %s", cnf.Broker)
if worker.Queu... | go | func (worker *Worker) LaunchAsync(errorsChan chan<- error) {
cnf := worker.server.GetConfig()
broker := worker.server.GetBroker()
// Log some useful information about worker configuration
log.INFO.Printf("Launching a worker with the following settings:")
log.INFO.Printf("- Broker: %s", cnf.Broker)
if worker.Queu... | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"LaunchAsync",
"(",
"errorsChan",
"chan",
"<-",
"error",
")",
"{",
"cnf",
":=",
"worker",
".",
"server",
".",
"GetConfig",
"(",
")",
"\n",
"broker",
":=",
"worker",
".",
"server",
".",
"GetBroker",
"(",
")",
... | // LaunchAsync is a non blocking version of Launch | [
"LaunchAsync",
"is",
"a",
"non",
"blocking",
"version",
"of",
"Launch"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L41-L107 | train |
RichardKnop/machinery | v1/worker.go | taskRetry | func (worker *Worker) taskRetry(signature *tasks.Signature) error {
// Update task state to RETRY
if err := worker.server.GetBackend().SetStateRetry(signature); err != nil {
return fmt.Errorf("Set state to 'retry' for task %s returned error: %s", signature.UUID, err)
}
// Decrement the retry counter, when it rea... | go | func (worker *Worker) taskRetry(signature *tasks.Signature) error {
// Update task state to RETRY
if err := worker.server.GetBackend().SetStateRetry(signature); err != nil {
return fmt.Errorf("Set state to 'retry' for task %s returned error: %s", signature.UUID, err)
}
// Decrement the retry counter, when it rea... | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"taskRetry",
"(",
"signature",
"*",
"tasks",
".",
"Signature",
")",
"error",
"{",
"// Update task state to RETRY",
"if",
"err",
":=",
"worker",
".",
"server",
".",
"GetBackend",
"(",
")",
".",
"SetStateRetry",
"(",
... | // retryTask decrements RetryCount counter and republishes the task to the queue | [
"retryTask",
"decrements",
"RetryCount",
"counter",
"and",
"republishes",
"the",
"task",
"to",
"the",
"queue"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L191-L212 | train |
RichardKnop/machinery | v1/worker.go | taskSucceeded | func (worker *Worker) taskSucceeded(signature *tasks.Signature, taskResults []*tasks.TaskResult) error {
// Update task state to SUCCESS
if err := worker.server.GetBackend().SetStateSuccess(signature, taskResults); err != nil {
return fmt.Errorf("Set state to 'success' for task %s returned error: %s", signature.UUI... | go | func (worker *Worker) taskSucceeded(signature *tasks.Signature, taskResults []*tasks.TaskResult) error {
// Update task state to SUCCESS
if err := worker.server.GetBackend().SetStateSuccess(signature, taskResults); err != nil {
return fmt.Errorf("Set state to 'success' for task %s returned error: %s", signature.UUI... | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"taskSucceeded",
"(",
"signature",
"*",
"tasks",
".",
"Signature",
",",
"taskResults",
"[",
"]",
"*",
"tasks",
".",
"TaskResult",
")",
"error",
"{",
"// Update task state to SUCCESS",
"if",
"err",
":=",
"worker",
".... | // taskSucceeded updates the task state and triggers success callbacks or a
// chord callback if this was the last task of a group with a chord callback | [
"taskSucceeded",
"updates",
"the",
"task",
"state",
"and",
"triggers",
"success",
"callbacks",
"or",
"a",
"chord",
"callback",
"if",
"this",
"was",
"the",
"last",
"task",
"of",
"a",
"group",
"with",
"a",
"chord",
"callback"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L234-L339 | train |
RichardKnop/machinery | v1/worker.go | taskFailed | func (worker *Worker) taskFailed(signature *tasks.Signature, taskErr error) error {
// Update task state to FAILURE
if err := worker.server.GetBackend().SetStateFailure(signature, taskErr.Error()); err != nil {
return fmt.Errorf("Set state to 'failure' for task %s returned error: %s", signature.UUID, err)
}
if w... | go | func (worker *Worker) taskFailed(signature *tasks.Signature, taskErr error) error {
// Update task state to FAILURE
if err := worker.server.GetBackend().SetStateFailure(signature, taskErr.Error()); err != nil {
return fmt.Errorf("Set state to 'failure' for task %s returned error: %s", signature.UUID, err)
}
if w... | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"taskFailed",
"(",
"signature",
"*",
"tasks",
".",
"Signature",
",",
"taskErr",
"error",
")",
"error",
"{",
"// Update task state to FAILURE",
"if",
"err",
":=",
"worker",
".",
"server",
".",
"GetBackend",
"(",
")",... | // taskFailed updates the task state and triggers error callbacks | [
"taskFailed",
"updates",
"the",
"task",
"state",
"and",
"triggers",
"error",
"callbacks"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L342-L366 | train |
RichardKnop/machinery | v1/worker.go | hasAMQPBackend | func (worker *Worker) hasAMQPBackend() bool {
_, ok := worker.server.GetBackend().(*amqp.Backend)
return ok
} | go | func (worker *Worker) hasAMQPBackend() bool {
_, ok := worker.server.GetBackend().(*amqp.Backend)
return ok
} | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"hasAMQPBackend",
"(",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"worker",
".",
"server",
".",
"GetBackend",
"(",
")",
".",
"(",
"*",
"amqp",
".",
"Backend",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // Returns true if the worker uses AMQP backend | [
"Returns",
"true",
"if",
"the",
"worker",
"uses",
"AMQP",
"backend"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L369-L372 | train |
RichardKnop/machinery | v1/common/amqp.go | Connect | func (ac *AMQPConnector) Connect(url string, tlsConfig *tls.Config, exchange, exchangeType, queueName string, queueDurable, queueDelete bool, queueBindingKey string, exchangeDeclareArgs, queueDeclareArgs, queueBindingArgs amqp.Table) (*amqp.Connection, *amqp.Channel, amqp.Queue, <-chan amqp.Confirmation, <-chan *amqp.E... | go | func (ac *AMQPConnector) Connect(url string, tlsConfig *tls.Config, exchange, exchangeType, queueName string, queueDurable, queueDelete bool, queueBindingKey string, exchangeDeclareArgs, queueDeclareArgs, queueBindingArgs amqp.Table) (*amqp.Connection, *amqp.Channel, amqp.Queue, <-chan amqp.Confirmation, <-chan *amqp.E... | [
"func",
"(",
"ac",
"*",
"AMQPConnector",
")",
"Connect",
"(",
"url",
"string",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
",",
"exchange",
",",
"exchangeType",
",",
"queueName",
"string",
",",
"queueDurable",
",",
"queueDelete",
"bool",
",",
"queueBindingK... | // Connect opens a connection to RabbitMQ, declares an exchange, opens a channel,
// declares and binds the queue and enables publish notifications | [
"Connect",
"opens",
"a",
"connection",
"to",
"RabbitMQ",
"declares",
"an",
"exchange",
"opens",
"a",
"channel",
"declares",
"and",
"binds",
"the",
"queue",
"and",
"enables",
"publish",
"notifications"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/amqp.go#L15-L70 | train |
RichardKnop/machinery | v1/common/amqp.go | DeleteQueue | func (ac *AMQPConnector) DeleteQueue(channel *amqp.Channel, queueName string) error {
// First return value is number of messages removed
_, err := channel.QueueDelete(
queueName, // name
false, // ifUnused
false, // ifEmpty
false, // noWait
)
return err
} | go | func (ac *AMQPConnector) DeleteQueue(channel *amqp.Channel, queueName string) error {
// First return value is number of messages removed
_, err := channel.QueueDelete(
queueName, // name
false, // ifUnused
false, // ifEmpty
false, // noWait
)
return err
} | [
"func",
"(",
"ac",
"*",
"AMQPConnector",
")",
"DeleteQueue",
"(",
"channel",
"*",
"amqp",
".",
"Channel",
",",
"queueName",
"string",
")",
"error",
"{",
"// First return value is number of messages removed",
"_",
",",
"err",
":=",
"channel",
".",
"QueueDelete",
... | // DeleteQueue deletes a queue by name | [
"DeleteQueue",
"deletes",
"a",
"queue",
"by",
"name"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/amqp.go#L73-L83 | train |
RichardKnop/machinery | v1/common/amqp.go | InspectQueue | func (*AMQPConnector) InspectQueue(channel *amqp.Channel, queueName string) (*amqp.Queue, error) {
queueState, err := channel.QueueInspect(queueName)
if err != nil {
return nil, fmt.Errorf("Queue inspect error: %s", err)
}
return &queueState, nil
} | go | func (*AMQPConnector) InspectQueue(channel *amqp.Channel, queueName string) (*amqp.Queue, error) {
queueState, err := channel.QueueInspect(queueName)
if err != nil {
return nil, fmt.Errorf("Queue inspect error: %s", err)
}
return &queueState, nil
} | [
"func",
"(",
"*",
"AMQPConnector",
")",
"InspectQueue",
"(",
"channel",
"*",
"amqp",
".",
"Channel",
",",
"queueName",
"string",
")",
"(",
"*",
"amqp",
".",
"Queue",
",",
"error",
")",
"{",
"queueState",
",",
"err",
":=",
"channel",
".",
"QueueInspect",
... | // InspectQueue provides information about a specific queue | [
"InspectQueue",
"provides",
"information",
"about",
"a",
"specific",
"queue"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/amqp.go#L86-L93 | train |
RichardKnop/machinery | v1/common/amqp.go | Open | func (ac *AMQPConnector) Open(url string, tlsConfig *tls.Config) (*amqp.Connection, *amqp.Channel, error) {
// Connect
// From amqp docs: DialTLS will use the provided tls.Config when it encounters an amqps:// scheme
// and will dial a plain connection when it encounters an amqp:// scheme.
conn, err := amqp.DialTLS... | go | func (ac *AMQPConnector) Open(url string, tlsConfig *tls.Config) (*amqp.Connection, *amqp.Channel, error) {
// Connect
// From amqp docs: DialTLS will use the provided tls.Config when it encounters an amqps:// scheme
// and will dial a plain connection when it encounters an amqp:// scheme.
conn, err := amqp.DialTLS... | [
"func",
"(",
"ac",
"*",
"AMQPConnector",
")",
"Open",
"(",
"url",
"string",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"(",
"*",
"amqp",
".",
"Connection",
",",
"*",
"amqp",
".",
"Channel",
",",
"error",
")",
"{",
"// Connect",
"// From amqp doc... | // Open new RabbitMQ connection | [
"Open",
"new",
"RabbitMQ",
"connection"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/amqp.go#L96-L112 | train |
RichardKnop/machinery | v1/tasks/task.go | SignatureFromContext | func SignatureFromContext(ctx context.Context) *Signature {
if ctx == nil {
return nil
}
v := ctx.Value(signatureCtx)
if v == nil {
return nil
}
signature, _ := v.(*Signature)
return signature
} | go | func SignatureFromContext(ctx context.Context) *Signature {
if ctx == nil {
return nil
}
v := ctx.Value(signatureCtx)
if v == nil {
return nil
}
signature, _ := v.(*Signature)
return signature
} | [
"func",
"SignatureFromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"Signature",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"v",
":=",
"ctx",
".",
"Value",
"(",
"signatureCtx",
")",
"\n",
"if",
"v",
"==",
"ni... | // SignatureFromContext gets the signature from the context | [
"SignatureFromContext",
"gets",
"the",
"signature",
"from",
"the",
"context"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tasks/task.go#L34-L46 | train |
RichardKnop/machinery | v1/tasks/task.go | NewWithSignature | func NewWithSignature(taskFunc interface{}, signature *Signature) (*Task, error) {
args := signature.Args
ctx := context.Background()
ctx = context.WithValue(ctx, signatureCtx, signature)
task := &Task{
TaskFunc: reflect.ValueOf(taskFunc),
Context: ctx,
}
taskFuncType := reflect.TypeOf(taskFunc)
if taskFun... | go | func NewWithSignature(taskFunc interface{}, signature *Signature) (*Task, error) {
args := signature.Args
ctx := context.Background()
ctx = context.WithValue(ctx, signatureCtx, signature)
task := &Task{
TaskFunc: reflect.ValueOf(taskFunc),
Context: ctx,
}
taskFuncType := reflect.TypeOf(taskFunc)
if taskFun... | [
"func",
"NewWithSignature",
"(",
"taskFunc",
"interface",
"{",
"}",
",",
"signature",
"*",
"Signature",
")",
"(",
"*",
"Task",
",",
"error",
")",
"{",
"args",
":=",
"signature",
".",
"Args",
"\n",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\... | // NewWithSignature is the same as New but injects the signature | [
"NewWithSignature",
"is",
"the",
"same",
"as",
"New",
"but",
"injects",
"the",
"signature"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tasks/task.go#L49-L71 | train |
RichardKnop/machinery | v1/tasks/task.go | New | func New(taskFunc interface{}, args []Arg) (*Task, error) {
task := &Task{
TaskFunc: reflect.ValueOf(taskFunc),
Context: context.Background(),
}
taskFuncType := reflect.TypeOf(taskFunc)
if taskFuncType.NumIn() > 0 {
arg0Type := taskFuncType.In(0)
if IsContextType(arg0Type) {
task.UseContext = true
}
... | go | func New(taskFunc interface{}, args []Arg) (*Task, error) {
task := &Task{
TaskFunc: reflect.ValueOf(taskFunc),
Context: context.Background(),
}
taskFuncType := reflect.TypeOf(taskFunc)
if taskFuncType.NumIn() > 0 {
arg0Type := taskFuncType.In(0)
if IsContextType(arg0Type) {
task.UseContext = true
}
... | [
"func",
"New",
"(",
"taskFunc",
"interface",
"{",
"}",
",",
"args",
"[",
"]",
"Arg",
")",
"(",
"*",
"Task",
",",
"error",
")",
"{",
"task",
":=",
"&",
"Task",
"{",
"TaskFunc",
":",
"reflect",
".",
"ValueOf",
"(",
"taskFunc",
")",
",",
"Context",
... | // New tries to use reflection to convert the function and arguments
// into a reflect.Value and prepare it for invocation | [
"New",
"tries",
"to",
"use",
"reflection",
"to",
"convert",
"the",
"function",
"and",
"arguments",
"into",
"a",
"reflect",
".",
"Value",
"and",
"prepare",
"it",
"for",
"invocation"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tasks/task.go#L75-L94 | train |
RichardKnop/machinery | v1/tracing/tracing.go | StartSpanFromHeaders | func StartSpanFromHeaders(headers tasks.Headers, operationName string) opentracing.Span {
// Try to extract the span context from the carrier.
spanContext, err := opentracing.GlobalTracer().Extract(opentracing.TextMap, headers)
// Create a new span from the span context if found or start a new trace with the functi... | go | func StartSpanFromHeaders(headers tasks.Headers, operationName string) opentracing.Span {
// Try to extract the span context from the carrier.
spanContext, err := opentracing.GlobalTracer().Extract(opentracing.TextMap, headers)
// Create a new span from the span context if found or start a new trace with the functi... | [
"func",
"StartSpanFromHeaders",
"(",
"headers",
"tasks",
".",
"Headers",
",",
"operationName",
"string",
")",
"opentracing",
".",
"Span",
"{",
"// Try to extract the span context from the carrier.",
"spanContext",
",",
"err",
":=",
"opentracing",
".",
"GlobalTracer",
"(... | // StartSpanFromHeaders will extract a span from the signature headers
// and start a new span with the given operation name. | [
"StartSpanFromHeaders",
"will",
"extract",
"a",
"span",
"from",
"the",
"signature",
"headers",
"and",
"start",
"a",
"new",
"span",
"with",
"the",
"given",
"operation",
"name",
"."
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tracing/tracing.go#L23-L41 | train |
RichardKnop/machinery | v1/tracing/tracing.go | HeadersWithSpan | func HeadersWithSpan(headers tasks.Headers, span opentracing.Span) tasks.Headers {
// check if the headers aren't nil
if headers == nil {
headers = make(tasks.Headers)
}
if err := opentracing.GlobalTracer().Inject(span.Context(), opentracing.TextMap, headers); err != nil {
span.LogFields(opentracing_log.Error(... | go | func HeadersWithSpan(headers tasks.Headers, span opentracing.Span) tasks.Headers {
// check if the headers aren't nil
if headers == nil {
headers = make(tasks.Headers)
}
if err := opentracing.GlobalTracer().Inject(span.Context(), opentracing.TextMap, headers); err != nil {
span.LogFields(opentracing_log.Error(... | [
"func",
"HeadersWithSpan",
"(",
"headers",
"tasks",
".",
"Headers",
",",
"span",
"opentracing",
".",
"Span",
")",
"tasks",
".",
"Headers",
"{",
"// check if the headers aren't nil",
"if",
"headers",
"==",
"nil",
"{",
"headers",
"=",
"make",
"(",
"tasks",
".",
... | // HeadersWithSpan will inject a span into the signature headers | [
"HeadersWithSpan",
"will",
"inject",
"a",
"span",
"into",
"the",
"signature",
"headers"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tracing/tracing.go#L44-L55 | train |
RichardKnop/machinery | v1/brokers/sqs/sqs.go | consume | func (b *Broker) consume(deliveries <-chan *awssqs.ReceiveMessageOutput, concurrency int, taskProcessor iface.TaskProcessor) error {
pool := make(chan struct{}, concurrency)
// initialize worker pool with maxWorkers workers
go func() {
b.initializePool(pool, concurrency)
}()
errorsChan := make(chan error)
fo... | go | func (b *Broker) consume(deliveries <-chan *awssqs.ReceiveMessageOutput, concurrency int, taskProcessor iface.TaskProcessor) error {
pool := make(chan struct{}, concurrency)
// initialize worker pool with maxWorkers workers
go func() {
b.initializePool(pool, concurrency)
}()
errorsChan := make(chan error)
fo... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"consume",
"(",
"deliveries",
"<-",
"chan",
"*",
"awssqs",
".",
"ReceiveMessageOutput",
",",
"concurrency",
"int",
",",
"taskProcessor",
"iface",
".",
"TaskProcessor",
")",
"error",
"{",
"pool",
":=",
"make",
"(",
"cha... | // consume is a method which keeps consuming deliveries from a channel, until there is an error or a stop signal | [
"consume",
"is",
"a",
"method",
"which",
"keeps",
"consuming",
"deliveries",
"from",
"a",
"channel",
"until",
"there",
"is",
"an",
"error",
"or",
"a",
"stop",
"signal"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/sqs/sqs.go#L184-L203 | train |
RichardKnop/machinery | v1/brokers/sqs/sqs.go | consumeOne | func (b *Broker) consumeOne(delivery *awssqs.ReceiveMessageOutput, taskProcessor iface.TaskProcessor) error {
if len(delivery.Messages) == 0 {
log.ERROR.Printf("received an empty message, the delivery was %v", delivery)
return errors.New("received empty message, the delivery is " + delivery.GoString())
}
sig :=... | go | func (b *Broker) consumeOne(delivery *awssqs.ReceiveMessageOutput, taskProcessor iface.TaskProcessor) error {
if len(delivery.Messages) == 0 {
log.ERROR.Printf("received an empty message, the delivery was %v", delivery)
return errors.New("received empty message, the delivery is " + delivery.GoString())
}
sig :=... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"consumeOne",
"(",
"delivery",
"*",
"awssqs",
".",
"ReceiveMessageOutput",
",",
"taskProcessor",
"iface",
".",
"TaskProcessor",
")",
"error",
"{",
"if",
"len",
"(",
"delivery",
".",
"Messages",
")",
"==",
"0",
"{",
"... | // consumeOne is a method consumes a delivery. If a delivery was consumed successfully, it will be deleted from AWS SQS | [
"consumeOne",
"is",
"a",
"method",
"consumes",
"a",
"delivery",
".",
"If",
"a",
"delivery",
"was",
"consumed",
"successfully",
"it",
"will",
"be",
"deleted",
"from",
"AWS",
"SQS"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/sqs/sqs.go#L206-L235 | train |
RichardKnop/machinery | v1/brokers/sqs/sqs.go | deleteOne | func (b *Broker) deleteOne(delivery *awssqs.ReceiveMessageOutput) error {
qURL := b.defaultQueueURL()
_, err := b.service.DeleteMessage(&awssqs.DeleteMessageInput{
QueueUrl: qURL,
ReceiptHandle: delivery.Messages[0].ReceiptHandle,
})
if err != nil {
return err
}
return nil
} | go | func (b *Broker) deleteOne(delivery *awssqs.ReceiveMessageOutput) error {
qURL := b.defaultQueueURL()
_, err := b.service.DeleteMessage(&awssqs.DeleteMessageInput{
QueueUrl: qURL,
ReceiptHandle: delivery.Messages[0].ReceiptHandle,
})
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"deleteOne",
"(",
"delivery",
"*",
"awssqs",
".",
"ReceiveMessageOutput",
")",
"error",
"{",
"qURL",
":=",
"b",
".",
"defaultQueueURL",
"(",
")",
"\n",
"_",
",",
"err",
":=",
"b",
".",
"service",
".",
"DeleteMessag... | // deleteOne is a method delete a delivery from AWS SQS | [
"deleteOne",
"is",
"a",
"method",
"delete",
"a",
"delivery",
"from",
"AWS",
"SQS"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/sqs/sqs.go#L238-L249 | train |
RichardKnop/machinery | v1/brokers/sqs/sqs.go | defaultQueueURL | func (b *Broker) defaultQueueURL() *string {
if b.queueUrl != nil {
return b.queueUrl
} else {
return aws.String(b.GetConfig().Broker + "/" + b.GetConfig().DefaultQueue)
}
} | go | func (b *Broker) defaultQueueURL() *string {
if b.queueUrl != nil {
return b.queueUrl
} else {
return aws.String(b.GetConfig().Broker + "/" + b.GetConfig().DefaultQueue)
}
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"defaultQueueURL",
"(",
")",
"*",
"string",
"{",
"if",
"b",
".",
"queueUrl",
"!=",
"nil",
"{",
"return",
"b",
".",
"queueUrl",
"\n",
"}",
"else",
"{",
"return",
"aws",
".",
"String",
"(",
"b",
".",
"GetConfig",... | // defaultQueueURL is a method returns the default queue url | [
"defaultQueueURL",
"is",
"a",
"method",
"returns",
"the",
"default",
"queue",
"url"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/sqs/sqs.go#L252-L259 | train |
RichardKnop/machinery | v1/brokers/sqs/sqs.go | receiveMessage | func (b *Broker) receiveMessage(qURL *string) (*awssqs.ReceiveMessageOutput, error) {
var waitTimeSeconds int
var visibilityTimeout *int
if b.GetConfig().SQS != nil {
waitTimeSeconds = b.GetConfig().SQS.WaitTimeSeconds
visibilityTimeout = b.GetConfig().SQS.VisibilityTimeout
} else {
waitTimeSeconds = 0
}
in... | go | func (b *Broker) receiveMessage(qURL *string) (*awssqs.ReceiveMessageOutput, error) {
var waitTimeSeconds int
var visibilityTimeout *int
if b.GetConfig().SQS != nil {
waitTimeSeconds = b.GetConfig().SQS.WaitTimeSeconds
visibilityTimeout = b.GetConfig().SQS.VisibilityTimeout
} else {
waitTimeSeconds = 0
}
in... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"receiveMessage",
"(",
"qURL",
"*",
"string",
")",
"(",
"*",
"awssqs",
".",
"ReceiveMessageOutput",
",",
"error",
")",
"{",
"var",
"waitTimeSeconds",
"int",
"\n",
"var",
"visibilityTimeout",
"*",
"int",
"\n",
"if",
"... | // receiveMessage is a method receives a message from specified queue url | [
"receiveMessage",
"is",
"a",
"method",
"receives",
"a",
"message",
"from",
"specified",
"queue",
"url"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/sqs/sqs.go#L262-L290 | train |
RichardKnop/machinery | v1/brokers/sqs/sqs.go | initializePool | func (b *Broker) initializePool(pool chan struct{}, concurrency int) {
for i := 0; i < concurrency; i++ {
pool <- struct{}{}
}
} | go | func (b *Broker) initializePool(pool chan struct{}, concurrency int) {
for i := 0; i < concurrency; i++ {
pool <- struct{}{}
}
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"initializePool",
"(",
"pool",
"chan",
"struct",
"{",
"}",
",",
"concurrency",
"int",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"concurrency",
";",
"i",
"++",
"{",
"pool",
"<-",
"struct",
"{",
"}",
"{",... | // initializePool is a method which initializes concurrency pool | [
"initializePool",
"is",
"a",
"method",
"which",
"initializes",
"concurrency",
"pool"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/sqs/sqs.go#L293-L297 | train |
RichardKnop/machinery | v1/brokers/sqs/sqs.go | consumeDeliveries | func (b *Broker) consumeDeliveries(deliveries <-chan *awssqs.ReceiveMessageOutput, concurrency int, taskProcessor iface.TaskProcessor, pool chan struct{}, errorsChan chan error) (bool, error) {
select {
case err := <-errorsChan:
return false, err
case d := <-deliveries:
if concurrency > 0 {
// get worker from... | go | func (b *Broker) consumeDeliveries(deliveries <-chan *awssqs.ReceiveMessageOutput, concurrency int, taskProcessor iface.TaskProcessor, pool chan struct{}, errorsChan chan error) (bool, error) {
select {
case err := <-errorsChan:
return false, err
case d := <-deliveries:
if concurrency > 0 {
// get worker from... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"consumeDeliveries",
"(",
"deliveries",
"<-",
"chan",
"*",
"awssqs",
".",
"ReceiveMessageOutput",
",",
"concurrency",
"int",
",",
"taskProcessor",
"iface",
".",
"TaskProcessor",
",",
"pool",
"chan",
"struct",
"{",
"}",
"... | // consumeDeliveries is a method consuming deliveries from deliveries channel | [
"consumeDeliveries",
"is",
"a",
"method",
"consuming",
"deliveries",
"from",
"deliveries",
"channel"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/sqs/sqs.go#L300-L331 | train |
RichardKnop/machinery | v1/brokers/sqs/sqs.go | continueReceivingMessages | func (b *Broker) continueReceivingMessages(qURL *string, deliveries chan *awssqs.ReceiveMessageOutput) (bool, error) {
select {
// A way to stop this goroutine from b.StopConsuming
case <-b.stopReceivingChan:
return false, nil
default:
output, err := b.receiveMessage(qURL)
if err != nil {
return true, err
... | go | func (b *Broker) continueReceivingMessages(qURL *string, deliveries chan *awssqs.ReceiveMessageOutput) (bool, error) {
select {
// A way to stop this goroutine from b.StopConsuming
case <-b.stopReceivingChan:
return false, nil
default:
output, err := b.receiveMessage(qURL)
if err != nil {
return true, err
... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"continueReceivingMessages",
"(",
"qURL",
"*",
"string",
",",
"deliveries",
"chan",
"*",
"awssqs",
".",
"ReceiveMessageOutput",
")",
"(",
"bool",
",",
"error",
")",
"{",
"select",
"{",
"// A way to stop this goroutine from b... | // continueReceivingMessages is a method returns a continue signal | [
"continueReceivingMessages",
"is",
"a",
"method",
"returns",
"a",
"continue",
"signal"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/sqs/sqs.go#L334-L350 | train |
RichardKnop/machinery | v1/brokers/sqs/sqs.go | getQueueURL | func (b *Broker) getQueueURL(taskProcessor iface.TaskProcessor) *string {
queueName := b.GetConfig().DefaultQueue
if taskProcessor.CustomQueue() != "" {
queueName = taskProcessor.CustomQueue()
}
return aws.String(b.GetConfig().Broker + "/" + queueName)
} | go | func (b *Broker) getQueueURL(taskProcessor iface.TaskProcessor) *string {
queueName := b.GetConfig().DefaultQueue
if taskProcessor.CustomQueue() != "" {
queueName = taskProcessor.CustomQueue()
}
return aws.String(b.GetConfig().Broker + "/" + queueName)
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"getQueueURL",
"(",
"taskProcessor",
"iface",
".",
"TaskProcessor",
")",
"*",
"string",
"{",
"queueName",
":=",
"b",
".",
"GetConfig",
"(",
")",
".",
"DefaultQueue",
"\n",
"if",
"taskProcessor",
".",
"CustomQueue",
"("... | // getQueueURL is a method returns that returns queueURL first by checking if custom queue was set and usign it
// otherwise using default queueName from config | [
"getQueueURL",
"is",
"a",
"method",
"returns",
"that",
"returns",
"queueURL",
"first",
"by",
"checking",
"if",
"custom",
"queue",
"was",
"set",
"and",
"usign",
"it",
"otherwise",
"using",
"default",
"queueName",
"from",
"config"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/sqs/sqs.go#L360-L367 | train |
RichardKnop/machinery | v1/tasks/workflow.go | GetUUIDs | func (group *Group) GetUUIDs() []string {
taskUUIDs := make([]string, len(group.Tasks))
for i, signature := range group.Tasks {
taskUUIDs[i] = signature.UUID
}
return taskUUIDs
} | go | func (group *Group) GetUUIDs() []string {
taskUUIDs := make([]string, len(group.Tasks))
for i, signature := range group.Tasks {
taskUUIDs[i] = signature.UUID
}
return taskUUIDs
} | [
"func",
"(",
"group",
"*",
"Group",
")",
"GetUUIDs",
"(",
")",
"[",
"]",
"string",
"{",
"taskUUIDs",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"group",
".",
"Tasks",
")",
")",
"\n",
"for",
"i",
",",
"signature",
":=",
"range",
"grou... | // GetUUIDs returns slice of task UUIDS | [
"GetUUIDs",
"returns",
"slice",
"of",
"task",
"UUIDS"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tasks/workflow.go#L28-L34 | train |
RichardKnop/machinery | v1/tasks/workflow.go | NewChain | func NewChain(signatures ...*Signature) (*Chain, error) {
// Auto generate task UUIDs if needed
for _, signature := range signatures {
if signature.UUID == "" {
signatureID := uuid.New().String()
signature.UUID = fmt.Sprintf("task_%v", signatureID)
}
}
for i := len(signatures) - 1; i > 0; i-- {
if i > ... | go | func NewChain(signatures ...*Signature) (*Chain, error) {
// Auto generate task UUIDs if needed
for _, signature := range signatures {
if signature.UUID == "" {
signatureID := uuid.New().String()
signature.UUID = fmt.Sprintf("task_%v", signatureID)
}
}
for i := len(signatures) - 1; i > 0; i-- {
if i > ... | [
"func",
"NewChain",
"(",
"signatures",
"...",
"*",
"Signature",
")",
"(",
"*",
"Chain",
",",
"error",
")",
"{",
"// Auto generate task UUIDs if needed",
"for",
"_",
",",
"signature",
":=",
"range",
"signatures",
"{",
"if",
"signature",
".",
"UUID",
"==",
"\"... | // NewChain creates a new chain of tasks to be processed one by one, passing
// results unless task signatures are set to be immutable | [
"NewChain",
"creates",
"a",
"new",
"chain",
"of",
"tasks",
"to",
"be",
"processed",
"one",
"by",
"one",
"passing",
"results",
"unless",
"task",
"signatures",
"are",
"set",
"to",
"be",
"immutable"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tasks/workflow.go#L38-L56 | train |
RichardKnop/machinery | v1/tasks/workflow.go | NewGroup | func NewGroup(signatures ...*Signature) (*Group, error) {
// Generate a group UUID
groupUUID := uuid.New().String()
groupID := fmt.Sprintf("group_%v", groupUUID)
// Auto generate task UUIDs if needed, group tasks by common group UUID
for _, signature := range signatures {
if signature.UUID == "" {
signatureI... | go | func NewGroup(signatures ...*Signature) (*Group, error) {
// Generate a group UUID
groupUUID := uuid.New().String()
groupID := fmt.Sprintf("group_%v", groupUUID)
// Auto generate task UUIDs if needed, group tasks by common group UUID
for _, signature := range signatures {
if signature.UUID == "" {
signatureI... | [
"func",
"NewGroup",
"(",
"signatures",
"...",
"*",
"Signature",
")",
"(",
"*",
"Group",
",",
"error",
")",
"{",
"// Generate a group UUID",
"groupUUID",
":=",
"uuid",
".",
"New",
"(",
")",
".",
"String",
"(",
")",
"\n",
"groupID",
":=",
"fmt",
".",
"Sp... | // NewGroup creates a new group of tasks to be processed in parallel | [
"NewGroup",
"creates",
"a",
"new",
"group",
"of",
"tasks",
"to",
"be",
"processed",
"in",
"parallel"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tasks/workflow.go#L59-L78 | train |
RichardKnop/machinery | v1/backends/amqp/amqp.go | GetState | func (b *Backend) GetState(taskUUID string) (*tasks.TaskState, error) {
declareQueueArgs := amqp.Table{
// Time in milliseconds
// after that message will expire
"x-message-ttl": int32(b.getExpiresIn()),
// Time after that the queue will be deleted.
"x-expires": int32(b.getExpiresIn()),
}
conn, channel, _,... | go | func (b *Backend) GetState(taskUUID string) (*tasks.TaskState, error) {
declareQueueArgs := amqp.Table{
// Time in milliseconds
// after that message will expire
"x-message-ttl": int32(b.getExpiresIn()),
// Time after that the queue will be deleted.
"x-expires": int32(b.getExpiresIn()),
}
conn, channel, _,... | [
"func",
"(",
"b",
"*",
"Backend",
")",
"GetState",
"(",
"taskUUID",
"string",
")",
"(",
"*",
"tasks",
".",
"TaskState",
",",
"error",
")",
"{",
"declareQueueArgs",
":=",
"amqp",
".",
"Table",
"{",
"// Time in milliseconds",
"// after that message will expire",
... | // GetState returns the latest task state. It will only return the status once
// as the message will get consumed and removed from the queue. | [
"GetState",
"returns",
"the",
"latest",
"task",
"state",
".",
"It",
"will",
"only",
"return",
"the",
"status",
"once",
"as",
"the",
"message",
"will",
"get",
"consumed",
"and",
"removed",
"from",
"the",
"queue",
"."
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/amqp/amqp.go#L190-L239 | train |
RichardKnop/machinery | v1/backends/amqp/amqp.go | getExpiresIn | func (b *Backend) getExpiresIn() int {
resultsExpireIn := b.GetConfig().ResultsExpireIn * 1000
if resultsExpireIn == 0 {
// // expire results after 1 hour by default
resultsExpireIn = config.DefaultResultsExpireIn * 1000
}
return resultsExpireIn
} | go | func (b *Backend) getExpiresIn() int {
resultsExpireIn := b.GetConfig().ResultsExpireIn * 1000
if resultsExpireIn == 0 {
// // expire results after 1 hour by default
resultsExpireIn = config.DefaultResultsExpireIn * 1000
}
return resultsExpireIn
} | [
"func",
"(",
"b",
"*",
"Backend",
")",
"getExpiresIn",
"(",
")",
"int",
"{",
"resultsExpireIn",
":=",
"b",
".",
"GetConfig",
"(",
")",
".",
"ResultsExpireIn",
"*",
"1000",
"\n",
"if",
"resultsExpireIn",
"==",
"0",
"{",
"// // expire results after 1 hour by def... | // getExpiresIn returns expiration time | [
"getExpiresIn",
"returns",
"expiration",
"time"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/amqp/amqp.go#L321-L328 | train |
RichardKnop/machinery | v1/common/redis.go | NewPool | func (rc *RedisConnector) NewPool(socketPath, host, password string, db int, cnf *config.RedisConfig, tlsConfig *tls.Config) *redis.Pool {
if cnf == nil {
cnf = defaultConfig
}
return &redis.Pool{
MaxIdle: cnf.MaxIdle,
IdleTimeout: time.Duration(cnf.IdleTimeout) * time.Second,
MaxActive: cnf.MaxActive,... | go | func (rc *RedisConnector) NewPool(socketPath, host, password string, db int, cnf *config.RedisConfig, tlsConfig *tls.Config) *redis.Pool {
if cnf == nil {
cnf = defaultConfig
}
return &redis.Pool{
MaxIdle: cnf.MaxIdle,
IdleTimeout: time.Duration(cnf.IdleTimeout) * time.Second,
MaxActive: cnf.MaxActive,... | [
"func",
"(",
"rc",
"*",
"RedisConnector",
")",
"NewPool",
"(",
"socketPath",
",",
"host",
",",
"password",
"string",
",",
"db",
"int",
",",
"cnf",
"*",
"config",
".",
"RedisConfig",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"*",
"redis",
".",
... | // NewPool returns a new pool of Redis connections | [
"NewPool",
"returns",
"a",
"new",
"pool",
"of",
"Redis",
"connections"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/redis.go#L26-L59 | train |
RichardKnop/machinery | v1/common/redis.go | open | func (rc *RedisConnector) open(socketPath, host, password string, db int, cnf *config.RedisConfig, tlsConfig *tls.Config) (redis.Conn, error) {
var opts = []redis.DialOption{
redis.DialDatabase(db),
redis.DialReadTimeout(time.Duration(cnf.ReadTimeout) * time.Second),
redis.DialWriteTimeout(time.Duration(cnf.Writ... | go | func (rc *RedisConnector) open(socketPath, host, password string, db int, cnf *config.RedisConfig, tlsConfig *tls.Config) (redis.Conn, error) {
var opts = []redis.DialOption{
redis.DialDatabase(db),
redis.DialReadTimeout(time.Duration(cnf.ReadTimeout) * time.Second),
redis.DialWriteTimeout(time.Duration(cnf.Writ... | [
"func",
"(",
"rc",
"*",
"RedisConnector",
")",
"open",
"(",
"socketPath",
",",
"host",
",",
"password",
"string",
",",
"db",
"int",
",",
"cnf",
"*",
"config",
".",
"RedisConfig",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"(",
"redis",
".",
"C... | // Open a new Redis connection | [
"Open",
"a",
"new",
"Redis",
"connection"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/redis.go#L62-L83 | train |
RichardKnop/machinery | v1/backends/result/async_result.go | NewAsyncResult | func NewAsyncResult(signature *tasks.Signature, backend iface.Backend) *AsyncResult {
return &AsyncResult{
Signature: signature,
taskState: new(tasks.TaskState),
backend: backend,
}
} | go | func NewAsyncResult(signature *tasks.Signature, backend iface.Backend) *AsyncResult {
return &AsyncResult{
Signature: signature,
taskState: new(tasks.TaskState),
backend: backend,
}
} | [
"func",
"NewAsyncResult",
"(",
"signature",
"*",
"tasks",
".",
"Signature",
",",
"backend",
"iface",
".",
"Backend",
")",
"*",
"AsyncResult",
"{",
"return",
"&",
"AsyncResult",
"{",
"Signature",
":",
"signature",
",",
"taskState",
":",
"new",
"(",
"tasks",
... | // NewAsyncResult creates AsyncResult instance | [
"NewAsyncResult",
"creates",
"AsyncResult",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/result/async_result.go#L40-L46 | train |
RichardKnop/machinery | v1/backends/result/async_result.go | NewChordAsyncResult | func NewChordAsyncResult(groupTasks []*tasks.Signature, chordCallback *tasks.Signature, backend iface.Backend) *ChordAsyncResult {
asyncResults := make([]*AsyncResult, len(groupTasks))
for i, task := range groupTasks {
asyncResults[i] = NewAsyncResult(task, backend)
}
return &ChordAsyncResult{
groupAsyncResults... | go | func NewChordAsyncResult(groupTasks []*tasks.Signature, chordCallback *tasks.Signature, backend iface.Backend) *ChordAsyncResult {
asyncResults := make([]*AsyncResult, len(groupTasks))
for i, task := range groupTasks {
asyncResults[i] = NewAsyncResult(task, backend)
}
return &ChordAsyncResult{
groupAsyncResults... | [
"func",
"NewChordAsyncResult",
"(",
"groupTasks",
"[",
"]",
"*",
"tasks",
".",
"Signature",
",",
"chordCallback",
"*",
"tasks",
".",
"Signature",
",",
"backend",
"iface",
".",
"Backend",
")",
"*",
"ChordAsyncResult",
"{",
"asyncResults",
":=",
"make",
"(",
"... | // NewChordAsyncResult creates ChordAsyncResult instance | [
"NewChordAsyncResult",
"creates",
"ChordAsyncResult",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/result/async_result.go#L49-L59 | train |
RichardKnop/machinery | v1/backends/result/async_result.go | NewChainAsyncResult | func NewChainAsyncResult(tasks []*tasks.Signature, backend iface.Backend) *ChainAsyncResult {
asyncResults := make([]*AsyncResult, len(tasks))
for i, task := range tasks {
asyncResults[i] = NewAsyncResult(task, backend)
}
return &ChainAsyncResult{
asyncResults: asyncResults,
backend: backend,
}
} | go | func NewChainAsyncResult(tasks []*tasks.Signature, backend iface.Backend) *ChainAsyncResult {
asyncResults := make([]*AsyncResult, len(tasks))
for i, task := range tasks {
asyncResults[i] = NewAsyncResult(task, backend)
}
return &ChainAsyncResult{
asyncResults: asyncResults,
backend: backend,
}
} | [
"func",
"NewChainAsyncResult",
"(",
"tasks",
"[",
"]",
"*",
"tasks",
".",
"Signature",
",",
"backend",
"iface",
".",
"Backend",
")",
"*",
"ChainAsyncResult",
"{",
"asyncResults",
":=",
"make",
"(",
"[",
"]",
"*",
"AsyncResult",
",",
"len",
"(",
"tasks",
... | // NewChainAsyncResult creates ChainAsyncResult instance | [
"NewChainAsyncResult",
"creates",
"ChainAsyncResult",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/result/async_result.go#L62-L71 | train |
RichardKnop/machinery | v1/backends/result/async_result.go | Touch | func (asyncResult *AsyncResult) Touch() ([]reflect.Value, error) {
if asyncResult.backend == nil {
return nil, ErrBackendNotConfigured
}
asyncResult.GetState()
// Purge state if we are using AMQP backend
if asyncResult.backend.IsAMQP() && asyncResult.taskState.IsCompleted() {
asyncResult.backend.PurgeState(a... | go | func (asyncResult *AsyncResult) Touch() ([]reflect.Value, error) {
if asyncResult.backend == nil {
return nil, ErrBackendNotConfigured
}
asyncResult.GetState()
// Purge state if we are using AMQP backend
if asyncResult.backend.IsAMQP() && asyncResult.taskState.IsCompleted() {
asyncResult.backend.PurgeState(a... | [
"func",
"(",
"asyncResult",
"*",
"AsyncResult",
")",
"Touch",
"(",
")",
"(",
"[",
"]",
"reflect",
".",
"Value",
",",
"error",
")",
"{",
"if",
"asyncResult",
".",
"backend",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrBackendNotConfigured",
"\n",
"}",
"... | // Touch the state and don't wait | [
"Touch",
"the",
"state",
"and",
"don",
"t",
"wait"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/result/async_result.go#L74-L95 | train |
RichardKnop/machinery | v1/backends/result/async_result.go | GetState | func (asyncResult *AsyncResult) GetState() *tasks.TaskState {
if asyncResult.taskState.IsCompleted() {
return asyncResult.taskState
}
taskState, err := asyncResult.backend.GetState(asyncResult.Signature.UUID)
if err == nil {
asyncResult.taskState = taskState
}
return asyncResult.taskState
} | go | func (asyncResult *AsyncResult) GetState() *tasks.TaskState {
if asyncResult.taskState.IsCompleted() {
return asyncResult.taskState
}
taskState, err := asyncResult.backend.GetState(asyncResult.Signature.UUID)
if err == nil {
asyncResult.taskState = taskState
}
return asyncResult.taskState
} | [
"func",
"(",
"asyncResult",
"*",
"AsyncResult",
")",
"GetState",
"(",
")",
"*",
"tasks",
".",
"TaskState",
"{",
"if",
"asyncResult",
".",
"taskState",
".",
"IsCompleted",
"(",
")",
"{",
"return",
"asyncResult",
".",
"taskState",
"\n",
"}",
"\n\n",
"taskSta... | // GetState returns latest task state | [
"GetState",
"returns",
"latest",
"task",
"state"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/result/async_result.go#L131-L142 | train |
RichardKnop/machinery | v1/tasks/validate.go | ValidateTask | func ValidateTask(task interface{}) error {
v := reflect.ValueOf(task)
t := v.Type()
// Task must be a function
if t.Kind() != reflect.Func {
return ErrTaskMustBeFunc
}
// Task must return at least a single value
if t.NumOut() < 1 {
return ErrTaskReturnsNoValue
}
// Last return value must be error
last... | go | func ValidateTask(task interface{}) error {
v := reflect.ValueOf(task)
t := v.Type()
// Task must be a function
if t.Kind() != reflect.Func {
return ErrTaskMustBeFunc
}
// Task must return at least a single value
if t.NumOut() < 1 {
return ErrTaskReturnsNoValue
}
// Last return value must be error
last... | [
"func",
"ValidateTask",
"(",
"task",
"interface",
"{",
"}",
")",
"error",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"task",
")",
"\n",
"t",
":=",
"v",
".",
"Type",
"(",
")",
"\n\n",
"// Task must be a function",
"if",
"t",
".",
"Kind",
"(",
")"... | // ValidateTask validates task function using reflection and makes sure
// it has a proper signature. Functions used as tasks must return at least a
// single value and the last return type must be error | [
"ValidateTask",
"validates",
"task",
"function",
"using",
"reflection",
"and",
"makes",
"sure",
"it",
"has",
"a",
"proper",
"signature",
".",
"Functions",
"used",
"as",
"tasks",
"must",
"return",
"at",
"least",
"a",
"single",
"value",
"and",
"the",
"last",
"... | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tasks/validate.go#L20-L42 | train |
RichardKnop/machinery | v1/backends/dynamodb/dynamodb.go | New | func New(cnf *config.Config) iface.Backend {
backend := &Backend{Backend: common.NewBackend(cnf), cnf: cnf}
if cnf.DynamoDB != nil && cnf.DynamoDB.Client != nil {
backend.client = cnf.DynamoDB.Client
} else {
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.Share... | go | func New(cnf *config.Config) iface.Backend {
backend := &Backend{Backend: common.NewBackend(cnf), cnf: cnf}
if cnf.DynamoDB != nil && cnf.DynamoDB.Client != nil {
backend.client = cnf.DynamoDB.Client
} else {
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.Share... | [
"func",
"New",
"(",
"cnf",
"*",
"config",
".",
"Config",
")",
"iface",
".",
"Backend",
"{",
"backend",
":=",
"&",
"Backend",
"{",
"Backend",
":",
"common",
".",
"NewBackend",
"(",
"cnf",
")",
",",
"cnf",
":",
"cnf",
"}",
"\n\n",
"if",
"cnf",
".",
... | // New creates a Backend instance | [
"New",
"creates",
"a",
"Backend",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/dynamodb/dynamodb.go#L29-L47 | train |
RichardKnop/machinery | v1/config/env.go | NewFromEnvironment | func NewFromEnvironment(keepReloading bool) (*Config, error) {
cnf, err := fromEnvironment()
if err != nil {
return nil, err
}
log.INFO.Print("Successfully loaded config from the environment")
if keepReloading {
// Open a goroutine to watch remote changes forever
go func() {
for {
// Delay after eac... | go | func NewFromEnvironment(keepReloading bool) (*Config, error) {
cnf, err := fromEnvironment()
if err != nil {
return nil, err
}
log.INFO.Print("Successfully loaded config from the environment")
if keepReloading {
// Open a goroutine to watch remote changes forever
go func() {
for {
// Delay after eac... | [
"func",
"NewFromEnvironment",
"(",
"keepReloading",
"bool",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"cnf",
",",
"err",
":=",
"fromEnvironment",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"l... | // NewFromEnvironment creates a config object from environment variables | [
"NewFromEnvironment",
"creates",
"a",
"config",
"object",
"from",
"environment",
"variables"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/config/env.go#L11-L40 | train |
RichardKnop/machinery | v1/common/broker.go | NewBroker | func NewBroker(cnf *config.Config) Broker {
return Broker{cnf: cnf, retry: true}
} | go | func NewBroker(cnf *config.Config) Broker {
return Broker{cnf: cnf, retry: true}
} | [
"func",
"NewBroker",
"(",
"cnf",
"*",
"config",
".",
"Config",
")",
"Broker",
"{",
"return",
"Broker",
"{",
"cnf",
":",
"cnf",
",",
"retry",
":",
"true",
"}",
"\n",
"}"
] | // NewBroker creates new Broker instance | [
"NewBroker",
"creates",
"new",
"Broker",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/broker.go#L24-L26 | train |
RichardKnop/machinery | v1/common/broker.go | IsTaskRegistered | func (b *Broker) IsTaskRegistered(name string) bool {
for _, registeredTaskName := range b.registeredTaskNames {
if registeredTaskName == name {
return true
}
}
return false
} | go | func (b *Broker) IsTaskRegistered(name string) bool {
for _, registeredTaskName := range b.registeredTaskNames {
if registeredTaskName == name {
return true
}
}
return false
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"IsTaskRegistered",
"(",
"name",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"registeredTaskName",
":=",
"range",
"b",
".",
"registeredTaskNames",
"{",
"if",
"registeredTaskName",
"==",
"name",
"{",
"return",
"true",
... | // IsTaskRegistered returns true if the task is registered with this broker | [
"IsTaskRegistered",
"returns",
"true",
"if",
"the",
"task",
"is",
"registered",
"with",
"this",
"broker"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/broker.go#L64-L71 | train |
RichardKnop/machinery | v1/common/broker.go | StartConsuming | func (b *Broker) StartConsuming(consumerTag string, concurrency int, taskProcessor iface.TaskProcessor) {
if b.retryFunc == nil {
b.retryFunc = retry.Closure()
}
b.stopChan = make(chan int)
b.retryStopChan = make(chan int)
} | go | func (b *Broker) StartConsuming(consumerTag string, concurrency int, taskProcessor iface.TaskProcessor) {
if b.retryFunc == nil {
b.retryFunc = retry.Closure()
}
b.stopChan = make(chan int)
b.retryStopChan = make(chan int)
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"StartConsuming",
"(",
"consumerTag",
"string",
",",
"concurrency",
"int",
",",
"taskProcessor",
"iface",
".",
"TaskProcessor",
")",
"{",
"if",
"b",
".",
"retryFunc",
"==",
"nil",
"{",
"b",
".",
"retryFunc",
"=",
"re... | // StartConsuming is a common part of StartConsuming method | [
"StartConsuming",
"is",
"a",
"common",
"part",
"of",
"StartConsuming",
"method"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/broker.go#L79-L86 | train |
RichardKnop/machinery | v1/common/broker.go | StopConsuming | func (b *Broker) StopConsuming() {
// Do not retry from now on
b.retry = false
// Stop the retry closure earlier
select {
case b.retryStopChan <- 1:
log.WARNING.Print("Stopping retry closure.")
default:
}
// Notifying the stop channel stops consuming of messages
select {
case b.stopChan <- 1:
log.WARNING.... | go | func (b *Broker) StopConsuming() {
// Do not retry from now on
b.retry = false
// Stop the retry closure earlier
select {
case b.retryStopChan <- 1:
log.WARNING.Print("Stopping retry closure.")
default:
}
// Notifying the stop channel stops consuming of messages
select {
case b.stopChan <- 1:
log.WARNING.... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"StopConsuming",
"(",
")",
"{",
"// Do not retry from now on",
"b",
".",
"retry",
"=",
"false",
"\n",
"// Stop the retry closure earlier",
"select",
"{",
"case",
"b",
".",
"retryStopChan",
"<-",
"1",
":",
"log",
".",
"WA... | // StopConsuming is a common part of StopConsuming | [
"StopConsuming",
"is",
"a",
"common",
"part",
"of",
"StopConsuming"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/broker.go#L89-L104 | train |
RichardKnop/machinery | v1/backends/memcache/memcache.go | lockGroupMeta | func (b *Backend) lockGroupMeta(groupMeta *tasks.GroupMeta) error {
groupMeta.Lock = true
encoded, err := json.Marshal(groupMeta)
if err != nil {
return err
}
return b.getClient().Set(&gomemcache.Item{
Key: groupMeta.GroupUUID,
Value: encoded,
Expiration: b.getExpirationTimestamp(),
})
} | go | func (b *Backend) lockGroupMeta(groupMeta *tasks.GroupMeta) error {
groupMeta.Lock = true
encoded, err := json.Marshal(groupMeta)
if err != nil {
return err
}
return b.getClient().Set(&gomemcache.Item{
Key: groupMeta.GroupUUID,
Value: encoded,
Expiration: b.getExpirationTimestamp(),
})
} | [
"func",
"(",
"b",
"*",
"Backend",
")",
"lockGroupMeta",
"(",
"groupMeta",
"*",
"tasks",
".",
"GroupMeta",
")",
"error",
"{",
"groupMeta",
".",
"Lock",
"=",
"true",
"\n",
"encoded",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"groupMeta",
")",
"\n",
... | // lockGroupMeta acquires lock on group meta data | [
"lockGroupMeta",
"acquires",
"lock",
"on",
"group",
"meta",
"data"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/memcache/memcache.go#L207-L219 | train |
RichardKnop/machinery | v1/backends/memcache/memcache.go | getExpirationTimestamp | func (b *Backend) getExpirationTimestamp() int32 {
expiresIn := b.GetConfig().ResultsExpireIn
if expiresIn == 0 {
// // expire results after 1 hour by default
expiresIn = config.DefaultResultsExpireIn
}
return int32(time.Now().Unix() + int64(expiresIn))
} | go | func (b *Backend) getExpirationTimestamp() int32 {
expiresIn := b.GetConfig().ResultsExpireIn
if expiresIn == 0 {
// // expire results after 1 hour by default
expiresIn = config.DefaultResultsExpireIn
}
return int32(time.Now().Unix() + int64(expiresIn))
} | [
"func",
"(",
"b",
"*",
"Backend",
")",
"getExpirationTimestamp",
"(",
")",
"int32",
"{",
"expiresIn",
":=",
"b",
".",
"GetConfig",
"(",
")",
".",
"ResultsExpireIn",
"\n",
"if",
"expiresIn",
"==",
"0",
"{",
"// // expire results after 1 hour by default",
"expires... | // getExpirationTimestamp returns expiration timestamp | [
"getExpirationTimestamp",
"returns",
"expiration",
"timestamp"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/memcache/memcache.go#L277-L284 | train |
RichardKnop/machinery | v1/backends/memcache/memcache.go | getClient | func (b *Backend) getClient() *gomemcache.Client {
if b.client == nil {
b.client = gomemcache.New(b.servers...)
}
return b.client
} | go | func (b *Backend) getClient() *gomemcache.Client {
if b.client == nil {
b.client = gomemcache.New(b.servers...)
}
return b.client
} | [
"func",
"(",
"b",
"*",
"Backend",
")",
"getClient",
"(",
")",
"*",
"gomemcache",
".",
"Client",
"{",
"if",
"b",
".",
"client",
"==",
"nil",
"{",
"b",
".",
"client",
"=",
"gomemcache",
".",
"New",
"(",
"b",
".",
"servers",
"...",
")",
"\n",
"}",
... | // getClient returns or creates instance of Memcache client | [
"getClient",
"returns",
"or",
"creates",
"instance",
"of",
"Memcache",
"client"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/memcache/memcache.go#L287-L292 | train |
RichardKnop/machinery | v1/backends/eager/eager.go | New | func New() iface.Backend {
return &Backend{
Backend: common.NewBackend(new(config.Config)),
groups: make(map[string][]string),
tasks: make(map[string][]byte),
}
} | go | func New() iface.Backend {
return &Backend{
Backend: common.NewBackend(new(config.Config)),
groups: make(map[string][]string),
tasks: make(map[string][]byte),
}
} | [
"func",
"New",
"(",
")",
"iface",
".",
"Backend",
"{",
"return",
"&",
"Backend",
"{",
"Backend",
":",
"common",
".",
"NewBackend",
"(",
"new",
"(",
"config",
".",
"Config",
")",
")",
",",
"groups",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
... | // New creates EagerBackend instance | [
"New",
"creates",
"EagerBackend",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/eager/eager.go#L54-L60 | train |
RichardKnop/machinery | v1/config/file.go | NewFromYaml | func NewFromYaml(cnfPath string, keepReloading bool) (*Config, error) {
cnf, err := fromFile(cnfPath)
if err != nil {
return nil, err
}
log.INFO.Printf("Successfully loaded config from file %s", cnfPath)
if keepReloading {
// Open a goroutine to watch remote changes forever
go func() {
for {
// Dela... | go | func NewFromYaml(cnfPath string, keepReloading bool) (*Config, error) {
cnf, err := fromFile(cnfPath)
if err != nil {
return nil, err
}
log.INFO.Printf("Successfully loaded config from file %s", cnfPath)
if keepReloading {
// Open a goroutine to watch remote changes forever
go func() {
for {
// Dela... | [
"func",
"NewFromYaml",
"(",
"cnfPath",
"string",
",",
"keepReloading",
"bool",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"cnf",
",",
"err",
":=",
"fromFile",
"(",
"cnfPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err"... | // NewFromYaml creates a config object from YAML file | [
"NewFromYaml",
"creates",
"a",
"config",
"object",
"from",
"YAML",
"file"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/config/file.go#L13-L42 | train |
RichardKnop/machinery | v1/config/file.go | ReadFromFile | func ReadFromFile(cnfPath string) ([]byte, error) {
file, err := os.Open(cnfPath)
// Config file not found
if err != nil {
return nil, fmt.Errorf("Open file error: %s", err)
}
// Config file found, let's try to read it
data := make([]byte, 1000)
count, err := file.Read(data)
if err != nil {
return nil, fm... | go | func ReadFromFile(cnfPath string) ([]byte, error) {
file, err := os.Open(cnfPath)
// Config file not found
if err != nil {
return nil, fmt.Errorf("Open file error: %s", err)
}
// Config file found, let's try to read it
data := make([]byte, 1000)
count, err := file.Read(data)
if err != nil {
return nil, fm... | [
"func",
"ReadFromFile",
"(",
"cnfPath",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"cnfPath",
")",
"\n\n",
"// Config file not found",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // ReadFromFile reads data from a file | [
"ReadFromFile",
"reads",
"data",
"from",
"a",
"file"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/config/file.go#L45-L61 | train |
RichardKnop/machinery | v1/tasks/signature.go | NewSignature | func NewSignature(name string, args []Arg) (*Signature, error) {
signatureID := uuid.New().String()
return &Signature{
UUID: fmt.Sprintf("task_%v", signatureID),
Name: name,
Args: args,
}, nil
} | go | func NewSignature(name string, args []Arg) (*Signature, error) {
signatureID := uuid.New().String()
return &Signature{
UUID: fmt.Sprintf("task_%v", signatureID),
Name: name,
Args: args,
}, nil
} | [
"func",
"NewSignature",
"(",
"name",
"string",
",",
"args",
"[",
"]",
"Arg",
")",
"(",
"*",
"Signature",
",",
"error",
")",
"{",
"signatureID",
":=",
"uuid",
".",
"New",
"(",
")",
".",
"String",
"(",
")",
"\n",
"return",
"&",
"Signature",
"{",
"UUI... | // NewSignature creates a new task signature | [
"NewSignature",
"creates",
"a",
"new",
"task",
"signature"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tasks/signature.go#L65-L72 | train |
RichardKnop/machinery | v1/server.go | NewServer | func NewServer(cnf *config.Config) (*Server, error) {
broker, err := BrokerFactory(cnf)
if err != nil {
return nil, err
}
// Backend is optional so we ignore the error
backend, _ := BackendFactory(cnf)
srv := NewServerWithBrokerBackend(cnf, broker, backend)
// init for eager-mode
eager, ok := broker.(eager... | go | func NewServer(cnf *config.Config) (*Server, error) {
broker, err := BrokerFactory(cnf)
if err != nil {
return nil, err
}
// Backend is optional so we ignore the error
backend, _ := BackendFactory(cnf)
srv := NewServerWithBrokerBackend(cnf, broker, backend)
// init for eager-mode
eager, ok := broker.(eager... | [
"func",
"NewServer",
"(",
"cnf",
"*",
"config",
".",
"Config",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"broker",
",",
"err",
":=",
"BrokerFactory",
"(",
"cnf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
... | // NewServer creates Server instance | [
"NewServer",
"creates",
"Server",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L42-L61 | train |
RichardKnop/machinery | v1/server.go | NewWorker | func (server *Server) NewWorker(consumerTag string, concurrency int) *Worker {
return &Worker{
server: server,
ConsumerTag: consumerTag,
Concurrency: concurrency,
Queue: "",
}
} | go | func (server *Server) NewWorker(consumerTag string, concurrency int) *Worker {
return &Worker{
server: server,
ConsumerTag: consumerTag,
Concurrency: concurrency,
Queue: "",
}
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"NewWorker",
"(",
"consumerTag",
"string",
",",
"concurrency",
"int",
")",
"*",
"Worker",
"{",
"return",
"&",
"Worker",
"{",
"server",
":",
"server",
",",
"ConsumerTag",
":",
"consumerTag",
",",
"Concurrency",
":"... | // NewWorker creates Worker instance | [
"NewWorker",
"creates",
"Worker",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L64-L71 | train |
RichardKnop/machinery | v1/server.go | NewCustomQueueWorker | func (server *Server) NewCustomQueueWorker(consumerTag string, concurrency int, queue string) *Worker {
return &Worker{
server: server,
ConsumerTag: consumerTag,
Concurrency: concurrency,
Queue: queue,
}
} | go | func (server *Server) NewCustomQueueWorker(consumerTag string, concurrency int, queue string) *Worker {
return &Worker{
server: server,
ConsumerTag: consumerTag,
Concurrency: concurrency,
Queue: queue,
}
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"NewCustomQueueWorker",
"(",
"consumerTag",
"string",
",",
"concurrency",
"int",
",",
"queue",
"string",
")",
"*",
"Worker",
"{",
"return",
"&",
"Worker",
"{",
"server",
":",
"server",
",",
"ConsumerTag",
":",
"co... | // NewCustomQueueWorker creates Worker instance with Custom Queue | [
"NewCustomQueueWorker",
"creates",
"Worker",
"instance",
"with",
"Custom",
"Queue"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L74-L81 | train |
RichardKnop/machinery | v1/server.go | RegisterTasks | func (server *Server) RegisterTasks(namedTaskFuncs map[string]interface{}) error {
for _, task := range namedTaskFuncs {
if err := tasks.ValidateTask(task); err != nil {
return err
}
}
server.registeredTasks = namedTaskFuncs
server.broker.SetRegisteredTaskNames(server.GetRegisteredTaskNames())
return nil
} | go | func (server *Server) RegisterTasks(namedTaskFuncs map[string]interface{}) error {
for _, task := range namedTaskFuncs {
if err := tasks.ValidateTask(task); err != nil {
return err
}
}
server.registeredTasks = namedTaskFuncs
server.broker.SetRegisteredTaskNames(server.GetRegisteredTaskNames())
return nil
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"RegisterTasks",
"(",
"namedTaskFuncs",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"for",
"_",
",",
"task",
":=",
"range",
"namedTaskFuncs",
"{",
"if",
"err",
":=",
"tasks",
".",
"Val... | // RegisterTasks registers all tasks at once | [
"RegisterTasks",
"registers",
"all",
"tasks",
"at",
"once"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L119-L128 | train |
RichardKnop/machinery | v1/server.go | RegisterTask | func (server *Server) RegisterTask(name string, taskFunc interface{}) error {
if err := tasks.ValidateTask(taskFunc); err != nil {
return err
}
server.registeredTasks[name] = taskFunc
server.broker.SetRegisteredTaskNames(server.GetRegisteredTaskNames())
return nil
} | go | func (server *Server) RegisterTask(name string, taskFunc interface{}) error {
if err := tasks.ValidateTask(taskFunc); err != nil {
return err
}
server.registeredTasks[name] = taskFunc
server.broker.SetRegisteredTaskNames(server.GetRegisteredTaskNames())
return nil
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"RegisterTask",
"(",
"name",
"string",
",",
"taskFunc",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"err",
":=",
"tasks",
".",
"ValidateTask",
"(",
"taskFunc",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
... | // RegisterTask registers a single task | [
"RegisterTask",
"registers",
"a",
"single",
"task"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L131-L138 | train |
RichardKnop/machinery | v1/server.go | IsTaskRegistered | func (server *Server) IsTaskRegistered(name string) bool {
_, ok := server.registeredTasks[name]
return ok
} | go | func (server *Server) IsTaskRegistered(name string) bool {
_, ok := server.registeredTasks[name]
return ok
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"IsTaskRegistered",
"(",
"name",
"string",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"server",
".",
"registeredTasks",
"[",
"name",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsTaskRegistered returns true if the task name is registered with this broker | [
"IsTaskRegistered",
"returns",
"true",
"if",
"the",
"task",
"name",
"is",
"registered",
"with",
"this",
"broker"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L141-L144 | train |
RichardKnop/machinery | v1/server.go | GetRegisteredTask | func (server *Server) GetRegisteredTask(name string) (interface{}, error) {
taskFunc, ok := server.registeredTasks[name]
if !ok {
return nil, fmt.Errorf("Task not registered error: %s", name)
}
return taskFunc, nil
} | go | func (server *Server) GetRegisteredTask(name string) (interface{}, error) {
taskFunc, ok := server.registeredTasks[name]
if !ok {
return nil, fmt.Errorf("Task not registered error: %s", name)
}
return taskFunc, nil
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"GetRegisteredTask",
"(",
"name",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"taskFunc",
",",
"ok",
":=",
"server",
".",
"registeredTasks",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{... | // GetRegisteredTask returns registered task by name | [
"GetRegisteredTask",
"returns",
"registered",
"task",
"by",
"name"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L147-L153 | train |
RichardKnop/machinery | v1/server.go | SendTaskWithContext | func (server *Server) SendTaskWithContext(ctx context.Context, signature *tasks.Signature) (*result.AsyncResult, error) {
span, _ := opentracing.StartSpanFromContext(ctx, "SendTask", tracing.ProducerOption(), tracing.MachineryTag)
defer span.Finish()
// tag the span with some info about the signature
signature.Hea... | go | func (server *Server) SendTaskWithContext(ctx context.Context, signature *tasks.Signature) (*result.AsyncResult, error) {
span, _ := opentracing.StartSpanFromContext(ctx, "SendTask", tracing.ProducerOption(), tracing.MachineryTag)
defer span.Finish()
// tag the span with some info about the signature
signature.Hea... | [
"func",
"(",
"server",
"*",
"Server",
")",
"SendTaskWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"signature",
"*",
"tasks",
".",
"Signature",
")",
"(",
"*",
"result",
".",
"AsyncResult",
",",
"error",
")",
"{",
"span",
",",
"_",
":=",
"ope... | // SendTaskWithContext will inject the trace context in the signature headers before publishing it | [
"SendTaskWithContext",
"will",
"inject",
"the",
"trace",
"context",
"in",
"the",
"signature",
"headers",
"before",
"publishing",
"it"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L156-L188 | train |
RichardKnop/machinery | v1/server.go | SendTask | func (server *Server) SendTask(signature *tasks.Signature) (*result.AsyncResult, error) {
return server.SendTaskWithContext(context.Background(), signature)
} | go | func (server *Server) SendTask(signature *tasks.Signature) (*result.AsyncResult, error) {
return server.SendTaskWithContext(context.Background(), signature)
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"SendTask",
"(",
"signature",
"*",
"tasks",
".",
"Signature",
")",
"(",
"*",
"result",
".",
"AsyncResult",
",",
"error",
")",
"{",
"return",
"server",
".",
"SendTaskWithContext",
"(",
"context",
".",
"Background",... | // SendTask publishes a task to the default queue | [
"SendTask",
"publishes",
"a",
"task",
"to",
"the",
"default",
"queue"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L191-L193 | train |
RichardKnop/machinery | v1/server.go | SendChainWithContext | func (server *Server) SendChainWithContext(ctx context.Context, chain *tasks.Chain) (*result.ChainAsyncResult, error) {
span, _ := opentracing.StartSpanFromContext(ctx, "SendChain", tracing.ProducerOption(), tracing.MachineryTag, tracing.WorkflowChainTag)
defer span.Finish()
tracing.AnnotateSpanWithChainInfo(span, ... | go | func (server *Server) SendChainWithContext(ctx context.Context, chain *tasks.Chain) (*result.ChainAsyncResult, error) {
span, _ := opentracing.StartSpanFromContext(ctx, "SendChain", tracing.ProducerOption(), tracing.MachineryTag, tracing.WorkflowChainTag)
defer span.Finish()
tracing.AnnotateSpanWithChainInfo(span, ... | [
"func",
"(",
"server",
"*",
"Server",
")",
"SendChainWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"chain",
"*",
"tasks",
".",
"Chain",
")",
"(",
"*",
"result",
".",
"ChainAsyncResult",
",",
"error",
")",
"{",
"span",
",",
"_",
":=",
"opent... | // SendChainWithContext will inject the trace context in all the signature headers before publishing it | [
"SendChainWithContext",
"will",
"inject",
"the",
"trace",
"context",
"in",
"all",
"the",
"signature",
"headers",
"before",
"publishing",
"it"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L196-L203 | train |
RichardKnop/machinery | v1/server.go | SendChain | func (server *Server) SendChain(chain *tasks.Chain) (*result.ChainAsyncResult, error) {
_, err := server.SendTask(chain.Tasks[0])
if err != nil {
return nil, err
}
return result.NewChainAsyncResult(chain.Tasks, server.backend), nil
} | go | func (server *Server) SendChain(chain *tasks.Chain) (*result.ChainAsyncResult, error) {
_, err := server.SendTask(chain.Tasks[0])
if err != nil {
return nil, err
}
return result.NewChainAsyncResult(chain.Tasks, server.backend), nil
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"SendChain",
"(",
"chain",
"*",
"tasks",
".",
"Chain",
")",
"(",
"*",
"result",
".",
"ChainAsyncResult",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"server",
".",
"SendTask",
"(",
"chain",
".",
"Tasks",
... | // SendChain triggers a chain of tasks | [
"SendChain",
"triggers",
"a",
"chain",
"of",
"tasks"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L206-L213 | train |
RichardKnop/machinery | v1/server.go | SendGroupWithContext | func (server *Server) SendGroupWithContext(ctx context.Context, group *tasks.Group, sendConcurrency int) ([]*result.AsyncResult, error) {
span, _ := opentracing.StartSpanFromContext(ctx, "SendGroup", tracing.ProducerOption(), tracing.MachineryTag, tracing.WorkflowGroupTag)
defer span.Finish()
tracing.AnnotateSpanWi... | go | func (server *Server) SendGroupWithContext(ctx context.Context, group *tasks.Group, sendConcurrency int) ([]*result.AsyncResult, error) {
span, _ := opentracing.StartSpanFromContext(ctx, "SendGroup", tracing.ProducerOption(), tracing.MachineryTag, tracing.WorkflowGroupTag)
defer span.Finish()
tracing.AnnotateSpanWi... | [
"func",
"(",
"server",
"*",
"Server",
")",
"SendGroupWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"group",
"*",
"tasks",
".",
"Group",
",",
"sendConcurrency",
"int",
")",
"(",
"[",
"]",
"*",
"result",
".",
"AsyncResult",
",",
"error",
")",
... | // SendGroupWithContext will inject the trace context in all the signature headers before publishing it | [
"SendGroupWithContext",
"will",
"inject",
"the",
"trace",
"context",
"in",
"all",
"the",
"signature",
"headers",
"before",
"publishing",
"it"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L216-L289 | train |
RichardKnop/machinery | v1/server.go | SendGroup | func (server *Server) SendGroup(group *tasks.Group, sendConcurrency int) ([]*result.AsyncResult, error) {
return server.SendGroupWithContext(context.Background(), group, sendConcurrency)
} | go | func (server *Server) SendGroup(group *tasks.Group, sendConcurrency int) ([]*result.AsyncResult, error) {
return server.SendGroupWithContext(context.Background(), group, sendConcurrency)
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"SendGroup",
"(",
"group",
"*",
"tasks",
".",
"Group",
",",
"sendConcurrency",
"int",
")",
"(",
"[",
"]",
"*",
"result",
".",
"AsyncResult",
",",
"error",
")",
"{",
"return",
"server",
".",
"SendGroupWithContext... | // SendGroup triggers a group of parallel tasks | [
"SendGroup",
"triggers",
"a",
"group",
"of",
"parallel",
"tasks"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L292-L294 | train |
RichardKnop/machinery | v1/server.go | SendChordWithContext | func (server *Server) SendChordWithContext(ctx context.Context, chord *tasks.Chord, sendConcurrency int) (*result.ChordAsyncResult, error) {
span, _ := opentracing.StartSpanFromContext(ctx, "SendChord", tracing.ProducerOption(), tracing.MachineryTag, tracing.WorkflowChordTag)
defer span.Finish()
tracing.AnnotateSpa... | go | func (server *Server) SendChordWithContext(ctx context.Context, chord *tasks.Chord, sendConcurrency int) (*result.ChordAsyncResult, error) {
span, _ := opentracing.StartSpanFromContext(ctx, "SendChord", tracing.ProducerOption(), tracing.MachineryTag, tracing.WorkflowChordTag)
defer span.Finish()
tracing.AnnotateSpa... | [
"func",
"(",
"server",
"*",
"Server",
")",
"SendChordWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"chord",
"*",
"tasks",
".",
"Chord",
",",
"sendConcurrency",
"int",
")",
"(",
"*",
"result",
".",
"ChordAsyncResult",
",",
"error",
")",
"{",
"... | // SendChordWithContext will inject the trace context in all the signature headers before publishing it | [
"SendChordWithContext",
"will",
"inject",
"the",
"trace",
"context",
"in",
"all",
"the",
"signature",
"headers",
"before",
"publishing",
"it"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L297-L313 | train |
RichardKnop/machinery | v1/server.go | SendChord | func (server *Server) SendChord(chord *tasks.Chord, sendConcurrency int) (*result.ChordAsyncResult, error) {
return server.SendChordWithContext(context.Background(), chord, sendConcurrency)
} | go | func (server *Server) SendChord(chord *tasks.Chord, sendConcurrency int) (*result.ChordAsyncResult, error) {
return server.SendChordWithContext(context.Background(), chord, sendConcurrency)
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"SendChord",
"(",
"chord",
"*",
"tasks",
".",
"Chord",
",",
"sendConcurrency",
"int",
")",
"(",
"*",
"result",
".",
"ChordAsyncResult",
",",
"error",
")",
"{",
"return",
"server",
".",
"SendChordWithContext",
"(",... | // SendChord triggers a group of parallel tasks with a callback | [
"SendChord",
"triggers",
"a",
"group",
"of",
"parallel",
"tasks",
"with",
"a",
"callback"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L316-L318 | train |
RichardKnop/machinery | v1/server.go | GetRegisteredTaskNames | func (server *Server) GetRegisteredTaskNames() []string {
taskNames := make([]string, len(server.registeredTasks))
var i = 0
for name := range server.registeredTasks {
taskNames[i] = name
i++
}
return taskNames
} | go | func (server *Server) GetRegisteredTaskNames() []string {
taskNames := make([]string, len(server.registeredTasks))
var i = 0
for name := range server.registeredTasks {
taskNames[i] = name
i++
}
return taskNames
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"GetRegisteredTaskNames",
"(",
")",
"[",
"]",
"string",
"{",
"taskNames",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"server",
".",
"registeredTasks",
")",
")",
"\n",
"var",
"i",
"=",
"0",
"\n",... | // GetRegisteredTaskNames returns slice of registered task names | [
"GetRegisteredTaskNames",
"returns",
"slice",
"of",
"registered",
"task",
"names"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/server.go#L321-L329 | train |
RichardKnop/machinery | v1/log/log.go | Set | func Set(l logging.LoggerInterface) {
DEBUG = l
INFO = l
WARNING = l
ERROR = l
FATAL = l
} | go | func Set(l logging.LoggerInterface) {
DEBUG = l
INFO = l
WARNING = l
ERROR = l
FATAL = l
} | [
"func",
"Set",
"(",
"l",
"logging",
".",
"LoggerInterface",
")",
"{",
"DEBUG",
"=",
"l",
"\n",
"INFO",
"=",
"l",
"\n",
"WARNING",
"=",
"l",
"\n",
"ERROR",
"=",
"l",
"\n",
"FATAL",
"=",
"l",
"\n",
"}"
] | // Set sets a custom logger for all log levels | [
"Set",
"sets",
"a",
"custom",
"logger",
"for",
"all",
"log",
"levels"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/log/log.go#L23-L29 | train |
RichardKnop/machinery | v1/brokers/redis/redis.go | GetPendingTasks | func (b *Broker) GetPendingTasks(queue string) ([]*tasks.Signature, error) {
conn := b.open()
defer conn.Close()
if queue == "" {
queue = b.GetConfig().DefaultQueue
}
dataBytes, err := conn.Do("LRANGE", queue, 0, -1)
if err != nil {
return nil, err
}
results, err := redis.ByteSlices(dataBytes, err)
if err... | go | func (b *Broker) GetPendingTasks(queue string) ([]*tasks.Signature, error) {
conn := b.open()
defer conn.Close()
if queue == "" {
queue = b.GetConfig().DefaultQueue
}
dataBytes, err := conn.Do("LRANGE", queue, 0, -1)
if err != nil {
return nil, err
}
results, err := redis.ByteSlices(dataBytes, err)
if err... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"GetPendingTasks",
"(",
"queue",
"string",
")",
"(",
"[",
"]",
"*",
"tasks",
".",
"Signature",
",",
"error",
")",
"{",
"conn",
":=",
"b",
".",
"open",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
... | // GetPendingTasks returns a slice of task signatures waiting in the queue | [
"GetPendingTasks",
"returns",
"a",
"slice",
"of",
"task",
"signatures",
"waiting",
"in",
"the",
"queue"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/redis/redis.go#L203-L230 | train |
RichardKnop/machinery | v1/brokers/redis/redis.go | nextTask | func (b *Broker) nextTask(queue string) (result []byte, err error) {
conn := b.open()
defer conn.Close()
items, err := redis.ByteSlices(conn.Do("BLPOP", queue, 1000))
if err != nil {
return []byte{}, err
}
// items[0] - the name of the key where an element was popped
// items[1] - the value of the popped ele... | go | func (b *Broker) nextTask(queue string) (result []byte, err error) {
conn := b.open()
defer conn.Close()
items, err := redis.ByteSlices(conn.Do("BLPOP", queue, 1000))
if err != nil {
return []byte{}, err
}
// items[0] - the name of the key where an element was popped
// items[1] - the value of the popped ele... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"nextTask",
"(",
"queue",
"string",
")",
"(",
"result",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"conn",
":=",
"b",
".",
"open",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n\n",
"ite... | // nextTask pops next available task from the default queue | [
"nextTask",
"pops",
"next",
"available",
"task",
"from",
"the",
"default",
"queue"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/redis/redis.go#L284-L302 | train |
RichardKnop/machinery | v1/brokers/redis/redis.go | open | func (b *Broker) open() redis.Conn {
b.redisOnce.Do(func() {
b.pool = b.NewPool(b.socketPath, b.host, b.password, b.db, b.GetConfig().Redis, b.GetConfig().TLSConfig)
b.redsync = redsync.New([]redsync.Pool{b.pool})
})
return b.pool.Get()
} | go | func (b *Broker) open() redis.Conn {
b.redisOnce.Do(func() {
b.pool = b.NewPool(b.socketPath, b.host, b.password, b.db, b.GetConfig().Redis, b.GetConfig().TLSConfig)
b.redsync = redsync.New([]redsync.Pool{b.pool})
})
return b.pool.Get()
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"open",
"(",
")",
"redis",
".",
"Conn",
"{",
"b",
".",
"redisOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"b",
".",
"pool",
"=",
"b",
".",
"NewPool",
"(",
"b",
".",
"socketPath",
",",
"b",
".",
"host",
... | // open returns or creates instance of Redis connection | [
"open",
"returns",
"or",
"creates",
"instance",
"of",
"Redis",
"connection"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/redis/redis.go#L378-L385 | train |
RichardKnop/machinery | v1/retry/fibonacci.go | Fibonacci | func Fibonacci() func() int {
a, b := 0, 1
return func() int {
a, b = b, a+b
return a
}
} | go | func Fibonacci() func() int {
a, b := 0, 1
return func() int {
a, b = b, a+b
return a
}
} | [
"func",
"Fibonacci",
"(",
")",
"func",
"(",
")",
"int",
"{",
"a",
",",
"b",
":=",
"0",
",",
"1",
"\n",
"return",
"func",
"(",
")",
"int",
"{",
"a",
",",
"b",
"=",
"b",
",",
"a",
"+",
"b",
"\n",
"return",
"a",
"\n",
"}",
"\n",
"}"
] | // Fibonacci returns successive Fibonacci numbers starting from 1 | [
"Fibonacci",
"returns",
"successive",
"Fibonacci",
"numbers",
"starting",
"from",
"1"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/retry/fibonacci.go#L4-L10 | train |
RichardKnop/machinery | v1/retry/fibonacci.go | FibonacciNext | func FibonacciNext(start int) int {
fib := Fibonacci()
num := fib()
for num <= start {
num = fib()
}
return num
} | go | func FibonacciNext(start int) int {
fib := Fibonacci()
num := fib()
for num <= start {
num = fib()
}
return num
} | [
"func",
"FibonacciNext",
"(",
"start",
"int",
")",
"int",
"{",
"fib",
":=",
"Fibonacci",
"(",
")",
"\n",
"num",
":=",
"fib",
"(",
")",
"\n",
"for",
"num",
"<=",
"start",
"{",
"num",
"=",
"fib",
"(",
")",
"\n",
"}",
"\n",
"return",
"num",
"\n",
... | // FibonacciNext returns next number in Fibonacci sequence greater than start | [
"FibonacciNext",
"returns",
"next",
"number",
"in",
"Fibonacci",
"sequence",
"greater",
"than",
"start"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/retry/fibonacci.go#L13-L20 | train |
RichardKnop/machinery | v1/backends/mongo/mongodb.go | decodeResults | func (b *Backend) decodeResults(results []*tasks.TaskResult) []*tasks.TaskResult {
l := len(results)
jsonResults := make([]*tasks.TaskResult, l, l)
for i, result := range results {
jsonResult := new(bson.M)
resultType := reflect.TypeOf(result.Value).Kind()
if resultType == reflect.String {
err := json.NewDe... | go | func (b *Backend) decodeResults(results []*tasks.TaskResult) []*tasks.TaskResult {
l := len(results)
jsonResults := make([]*tasks.TaskResult, l, l)
for i, result := range results {
jsonResult := new(bson.M)
resultType := reflect.TypeOf(result.Value).Kind()
if resultType == reflect.String {
err := json.NewDe... | [
"func",
"(",
"b",
"*",
"Backend",
")",
"decodeResults",
"(",
"results",
"[",
"]",
"*",
"tasks",
".",
"TaskResult",
")",
"[",
"]",
"*",
"tasks",
".",
"TaskResult",
"{",
"l",
":=",
"len",
"(",
"results",
")",
"\n",
"jsonResults",
":=",
"make",
"(",
"... | // decodeResults detects & decodes json strings in TaskResult.Value and returns a new slice | [
"decodeResults",
"detects",
"&",
"decodes",
"json",
"strings",
"in",
"TaskResult",
".",
"Value",
"and",
"returns",
"a",
"new",
"slice"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/mongo/mongodb.go#L148-L167 | train |
RichardKnop/machinery | v1/backends/mongo/mongodb.go | lockGroupMeta | func (b *Backend) lockGroupMeta(groupUUID string) error {
query := bson.M{
"_id": groupUUID,
"lock": false,
}
change := bson.M{
"$set": bson.M{
"lock": true,
},
}
_, err := b.groupMetasCollection.UpdateOne(context.Background(), query, change, options.Update().SetUpsert(true))
return err
} | go | func (b *Backend) lockGroupMeta(groupUUID string) error {
query := bson.M{
"_id": groupUUID,
"lock": false,
}
change := bson.M{
"$set": bson.M{
"lock": true,
},
}
_, err := b.groupMetasCollection.UpdateOne(context.Background(), query, change, options.Update().SetUpsert(true))
return err
} | [
"func",
"(",
"b",
"*",
"Backend",
")",
"lockGroupMeta",
"(",
"groupUUID",
"string",
")",
"error",
"{",
"query",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"groupUUID",
",",
"\"",
"\"",
":",
"false",
",",
"}",
"\n",
"change",
":=",
"bson",
".",
... | // lockGroupMeta acquires lock on groupUUID document | [
"lockGroupMeta",
"acquires",
"lock",
"on",
"groupUUID",
"document"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/mongo/mongodb.go#L199-L213 | train |
RichardKnop/machinery | v1/backends/mongo/mongodb.go | unlockGroupMeta | func (b *Backend) unlockGroupMeta(groupUUID string) error {
update := bson.M{"$set": bson.M{"lock": false}}
_, err := b.groupMetasCollection.UpdateOne(context.Background(), bson.M{"_id": groupUUID}, update, options.Update())
return err
} | go | func (b *Backend) unlockGroupMeta(groupUUID string) error {
update := bson.M{"$set": bson.M{"lock": false}}
_, err := b.groupMetasCollection.UpdateOne(context.Background(), bson.M{"_id": groupUUID}, update, options.Update())
return err
} | [
"func",
"(",
"b",
"*",
"Backend",
")",
"unlockGroupMeta",
"(",
"groupUUID",
"string",
")",
"error",
"{",
"update",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"false",
"}",
"}",
"\n",
"_",
",",
"err",
"... | // unlockGroupMeta releases lock on groupUUID document | [
"unlockGroupMeta",
"releases",
"lock",
"on",
"groupUUID",
"document"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/mongo/mongodb.go#L216-L220 | train |
RichardKnop/machinery | v1/backends/mongo/mongodb.go | connect | func (b *Backend) connect() error {
client, err := b.dial()
if err != nil {
return err
}
b.client = client
database := "machinery"
if b.GetConfig().MongoDB != nil {
database = b.GetConfig().MongoDB.Database
}
b.tasksCollection = b.client.Database(database).Collection("tasks")
b.groupMetasCollection = b.... | go | func (b *Backend) connect() error {
client, err := b.dial()
if err != nil {
return err
}
b.client = client
database := "machinery"
if b.GetConfig().MongoDB != nil {
database = b.GetConfig().MongoDB.Database
}
b.tasksCollection = b.client.Database(database).Collection("tasks")
b.groupMetasCollection = b.... | [
"func",
"(",
"b",
"*",
"Backend",
")",
"connect",
"(",
")",
"error",
"{",
"client",
",",
"err",
":=",
"b",
".",
"dial",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"b",
".",
"client",
"=",
"client",
"\n\n",
... | // connect creates the underlying mgo connection if it doesn't exist
// creates required indexes for our collections | [
"connect",
"creates",
"the",
"underlying",
"mgo",
"connection",
"if",
"it",
"doesn",
"t",
"exist",
"creates",
"required",
"indexes",
"for",
"our",
"collections"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/mongo/mongodb.go#L265-L286 | train |
RichardKnop/machinery | v1/backends/mongo/mongodb.go | dial | func (b *Backend) dial() (*mongo.Client, error) {
if b.GetConfig().MongoDB != nil && b.GetConfig().MongoDB.Client != nil {
return b.GetConfig().MongoDB.Client, nil
}
uri := b.GetConfig().ResultBackend
if strings.HasPrefix(uri, "mongodb://") == false &&
strings.HasPrefix(uri, "mongodb+srv://") == false {
uri... | go | func (b *Backend) dial() (*mongo.Client, error) {
if b.GetConfig().MongoDB != nil && b.GetConfig().MongoDB.Client != nil {
return b.GetConfig().MongoDB.Client, nil
}
uri := b.GetConfig().ResultBackend
if strings.HasPrefix(uri, "mongodb://") == false &&
strings.HasPrefix(uri, "mongodb+srv://") == false {
uri... | [
"func",
"(",
"b",
"*",
"Backend",
")",
"dial",
"(",
")",
"(",
"*",
"mongo",
".",
"Client",
",",
"error",
")",
"{",
"if",
"b",
".",
"GetConfig",
"(",
")",
".",
"MongoDB",
"!=",
"nil",
"&&",
"b",
".",
"GetConfig",
"(",
")",
".",
"MongoDB",
".",
... | // dial connects to mongo with TLSConfig if provided
// else connects via ResultBackend uri | [
"dial",
"connects",
"to",
"mongo",
"with",
"TLSConfig",
"if",
"provided",
"else",
"connects",
"via",
"ResultBackend",
"uri"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/mongo/mongodb.go#L290-L315 | train |
RichardKnop/machinery | v1/backends/mongo/mongodb.go | createMongoIndexes | func (b *Backend) createMongoIndexes(database string) error {
tasksCollection := b.client.Database(database).Collection("tasks")
expireIn := int32(b.GetConfig().ResultsExpireIn)
_, err := tasksCollection.Indexes().CreateMany(context.Background(), []mongo.IndexModel{
{
Keys: bson.M{"state": 1},
Options:... | go | func (b *Backend) createMongoIndexes(database string) error {
tasksCollection := b.client.Database(database).Collection("tasks")
expireIn := int32(b.GetConfig().ResultsExpireIn)
_, err := tasksCollection.Indexes().CreateMany(context.Background(), []mongo.IndexModel{
{
Keys: bson.M{"state": 1},
Options:... | [
"func",
"(",
"b",
"*",
"Backend",
")",
"createMongoIndexes",
"(",
"database",
"string",
")",
"error",
"{",
"tasksCollection",
":=",
"b",
".",
"client",
".",
"Database",
"(",
"database",
")",
".",
"Collection",
"(",
"\"",
"\"",
")",
"\n\n",
"expireIn",
":... | // createMongoIndexes ensures all indexes are in place | [
"createMongoIndexes",
"ensures",
"all",
"indexes",
"are",
"in",
"place"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/mongo/mongodb.go#L318-L339 | train |
RichardKnop/machinery | v1/brokers/errs/errors.go | NewErrCouldNotUnmarshaTaskSignature | func NewErrCouldNotUnmarshaTaskSignature(msg []byte, err error) ErrCouldNotUnmarshaTaskSignature {
return ErrCouldNotUnmarshaTaskSignature{msg: msg, reason: err.Error()}
} | go | func NewErrCouldNotUnmarshaTaskSignature(msg []byte, err error) ErrCouldNotUnmarshaTaskSignature {
return ErrCouldNotUnmarshaTaskSignature{msg: msg, reason: err.Error()}
} | [
"func",
"NewErrCouldNotUnmarshaTaskSignature",
"(",
"msg",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"ErrCouldNotUnmarshaTaskSignature",
"{",
"return",
"ErrCouldNotUnmarshaTaskSignature",
"{",
"msg",
":",
"msg",
",",
"reason",
":",
"err",
".",
"Error",
"(",
")",... | // NewErrCouldNotUnmarshaTaskSignature returns new ErrCouldNotUnmarshaTaskSignature instance | [
"NewErrCouldNotUnmarshaTaskSignature",
"returns",
"new",
"ErrCouldNotUnmarshaTaskSignature",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/errs/errors.go#L19-L21 | train |
RichardKnop/machinery | v1/tasks/errors.go | NewErrRetryTaskLater | func NewErrRetryTaskLater(msg string, retryIn time.Duration) ErrRetryTaskLater {
return ErrRetryTaskLater{msg: msg, retryIn: retryIn}
} | go | func NewErrRetryTaskLater(msg string, retryIn time.Duration) ErrRetryTaskLater {
return ErrRetryTaskLater{msg: msg, retryIn: retryIn}
} | [
"func",
"NewErrRetryTaskLater",
"(",
"msg",
"string",
",",
"retryIn",
"time",
".",
"Duration",
")",
"ErrRetryTaskLater",
"{",
"return",
"ErrRetryTaskLater",
"{",
"msg",
":",
"msg",
",",
"retryIn",
":",
"retryIn",
"}",
"\n",
"}"
] | // NewErrRetryTaskLater returns new ErrRetryTaskLater instance | [
"NewErrRetryTaskLater",
"returns",
"new",
"ErrRetryTaskLater",
"instance"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/tasks/errors.go#L25-L27 | train |
RichardKnop/machinery | v1/backends/redis/redis.go | setExpirationTime | func (b *Backend) setExpirationTime(key string) error {
expiresIn := b.GetConfig().ResultsExpireIn
if expiresIn == 0 {
// // expire results after 1 hour by default
expiresIn = config.DefaultResultsExpireIn
}
expirationTimestamp := int32(time.Now().Unix() + int64(expiresIn))
conn := b.open()
defer conn.Close(... | go | func (b *Backend) setExpirationTime(key string) error {
expiresIn := b.GetConfig().ResultsExpireIn
if expiresIn == 0 {
// // expire results after 1 hour by default
expiresIn = config.DefaultResultsExpireIn
}
expirationTimestamp := int32(time.Now().Unix() + int64(expiresIn))
conn := b.open()
defer conn.Close(... | [
"func",
"(",
"b",
"*",
"Backend",
")",
"setExpirationTime",
"(",
"key",
"string",
")",
"error",
"{",
"expiresIn",
":=",
"b",
".",
"GetConfig",
"(",
")",
".",
"ResultsExpireIn",
"\n",
"if",
"expiresIn",
"==",
"0",
"{",
"// // expire results after 1 hour by defa... | // setExpirationTime sets expiration timestamp on a stored task state | [
"setExpirationTime",
"sets",
"expiration",
"timestamp",
"on",
"a",
"stored",
"task",
"state"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/backends/redis/redis.go#L312-L329 | train |
RichardKnop/machinery | v1/brokers/amqp/amqp.go | GetOrOpenConnection | func (b *Broker) GetOrOpenConnection(queueName string, queueBindingKey string, exchangeDeclareArgs, queueDeclareArgs, queueBindingArgs amqp.Table) (*AMQPConnection, error) {
var err error
b.connectionsMutex.Lock()
defer b.connectionsMutex.Unlock()
conn, ok := b.connections[queueName]
if !ok {
conn = &AMQPConne... | go | func (b *Broker) GetOrOpenConnection(queueName string, queueBindingKey string, exchangeDeclareArgs, queueDeclareArgs, queueBindingArgs amqp.Table) (*AMQPConnection, error) {
var err error
b.connectionsMutex.Lock()
defer b.connectionsMutex.Unlock()
conn, ok := b.connections[queueName]
if !ok {
conn = &AMQPConne... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"GetOrOpenConnection",
"(",
"queueName",
"string",
",",
"queueBindingKey",
"string",
",",
"exchangeDeclareArgs",
",",
"queueDeclareArgs",
",",
"queueBindingArgs",
"amqp",
".",
"Table",
")",
"(",
"*",
"AMQPConnection",
",",
"... | // GetOrOpenConnection will return a connection on a particular queue name. Open connections
// are saved to avoid having to reopen connection for multiple queues | [
"GetOrOpenConnection",
"will",
"return",
"a",
"connection",
"on",
"a",
"particular",
"queue",
"name",
".",
"Open",
"connections",
"are",
"saved",
"to",
"avoid",
"having",
"to",
"reopen",
"connection",
"for",
"multiple",
"queues"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/amqp/amqp.go#L117-L163 | train |
RichardKnop/machinery | v1/brokers/amqp/amqp.go | delay | func (b *Broker) delay(signature *tasks.Signature, delayMs int64) error {
if delayMs <= 0 {
return errors.New("Cannot delay task by 0ms")
}
message, err := json.Marshal(signature)
if err != nil {
return fmt.Errorf("JSON marshal error: %s", err)
}
// It's necessary to redeclare the queue each time (to zero i... | go | func (b *Broker) delay(signature *tasks.Signature, delayMs int64) error {
if delayMs <= 0 {
return errors.New("Cannot delay task by 0ms")
}
message, err := json.Marshal(signature)
if err != nil {
return fmt.Errorf("JSON marshal error: %s", err)
}
// It's necessary to redeclare the queue each time (to zero i... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"delay",
"(",
"signature",
"*",
"tasks",
".",
"Signature",
",",
"delayMs",
"int64",
")",
"error",
"{",
"if",
"delayMs",
"<=",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
... | // delay a task by delayDuration miliseconds, the way it works is a new queue
// is created without any consumers, the message is then published to this queue
// with appropriate ttl expiration headers, after the expiration, it is sent to
// the proper queue with consumers | [
"delay",
"a",
"task",
"by",
"delayDuration",
"miliseconds",
"the",
"way",
"it",
"works",
"is",
"a",
"new",
"queue",
"is",
"created",
"without",
"any",
"consumers",
"the",
"message",
"is",
"then",
"published",
"to",
"this",
"queue",
"with",
"appropriate",
"tt... | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/brokers/amqp/amqp.go#L327-L390 | train |
cri-o/cri-o | server/version.go | Version | func (s *Server) Version(ctx context.Context, req *pb.VersionRequest) (resp *pb.VersionResponse, err error) {
const operation = "version"
defer func() {
recordOperation(operation, time.Now())
recordError(operation, err)
}()
return &pb.VersionResponse{
Version: kubeAPIVersion,
RuntimeName: c... | go | func (s *Server) Version(ctx context.Context, req *pb.VersionRequest) (resp *pb.VersionResponse, err error) {
const operation = "version"
defer func() {
recordOperation(operation, time.Now())
recordError(operation, err)
}()
return &pb.VersionResponse{
Version: kubeAPIVersion,
RuntimeName: c... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Version",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"pb",
".",
"VersionRequest",
")",
"(",
"resp",
"*",
"pb",
".",
"VersionResponse",
",",
"err",
"error",
")",
"{",
"const",
"operation",
"=",
"\"",... | // Version returns the runtime name, runtime version and runtime API version | [
"Version",
"returns",
"the",
"runtime",
"name",
"runtime",
"version",
"and",
"runtime",
"API",
"version"
] | 0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5 | https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/version.go#L22-L35 | train |
cri-o/cri-o | lib/sandbox/sandbox.go | NetNsGet | func (s *Sandbox) NetNsGet(nspath, name string) (*NetNs, error) {
if err := ns.IsNSorErr(nspath); err != nil {
return nil, ErrClosedNetNS
}
symlink, symlinkErr := isSymbolicLink(nspath)
if symlinkErr != nil {
return nil, symlinkErr
}
var resolvedNsPath string
if symlink {
path, err := os.Readlink(nspath)... | go | func (s *Sandbox) NetNsGet(nspath, name string) (*NetNs, error) {
if err := ns.IsNSorErr(nspath); err != nil {
return nil, ErrClosedNetNS
}
symlink, symlinkErr := isSymbolicLink(nspath)
if symlinkErr != nil {
return nil, symlinkErr
}
var resolvedNsPath string
if symlink {
path, err := os.Readlink(nspath)... | [
"func",
"(",
"s",
"*",
"Sandbox",
")",
"NetNsGet",
"(",
"nspath",
",",
"name",
"string",
")",
"(",
"*",
"NetNs",
",",
"error",
")",
"{",
"if",
"err",
":=",
"ns",
".",
"IsNSorErr",
"(",
"nspath",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",... | // NetNsGet returns the NetNs associated with the given nspath and name | [
"NetNsGet",
"returns",
"the",
"NetNs",
"associated",
"with",
"the",
"given",
"nspath",
"and",
"name"
] | 0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5 | https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L28-L66 | train |
cri-o/cri-o | lib/sandbox/sandbox.go | New | func New(id, namespace, name, kubeName, logDir string, labels, annotations map[string]string, processLabel, mountLabel string, metadata *pb.PodSandboxMetadata, shmPath, cgroupParent string, privileged bool, runtimeHandler string, resolvPath, hostname string, portMappings []*hostport.PortMapping, hostNetwork bool) (*San... | go | func New(id, namespace, name, kubeName, logDir string, labels, annotations map[string]string, processLabel, mountLabel string, metadata *pb.PodSandboxMetadata, shmPath, cgroupParent string, privileged bool, runtimeHandler string, resolvPath, hostname string, portMappings []*hostport.PortMapping, hostNetwork bool) (*San... | [
"func",
"New",
"(",
"id",
",",
"namespace",
",",
"name",
",",
"kubeName",
",",
"logDir",
"string",
",",
"labels",
",",
"annotations",
"map",
"[",
"string",
"]",
"string",
",",
"processLabel",
",",
"mountLabel",
"string",
",",
"metadata",
"*",
"pb",
".",
... | // New creates and populates a new pod sandbox
// New sandboxes have no containers, no infra container, and no network namespaces associated with them
// An infra container must be attached before the sandbox is added to the state | [
"New",
"creates",
"and",
"populates",
"a",
"new",
"pod",
"sandbox",
"New",
"sandboxes",
"have",
"no",
"containers",
"no",
"infra",
"container",
"and",
"no",
"network",
"namespaces",
"associated",
"with",
"them",
"An",
"infra",
"container",
"must",
"be",
"attac... | 0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5 | https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L152-L176 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.