func main() { backend := backend.Backend{Implementation: "memory", Address: ""} flag.Var(&backend, "backend", "impl[:address] of the storage backend") bootstrap := flag.Bool("bootstrap", true, "Create initial work specs") nsName := flag.String("namespace", "", "Coordinate namespace name") flag.Parse() coordinateRoot, err := backend.Coordinate() if err != nil { panic(err) } namespace, err := coordinateRoot.Namespace(*nsName) if err != nil { panic(err) } if *bootstrap { err = createWorkSpecs(namespace) if err != nil { panic(err) } } tasks := map[string]func(context.Context, []coordinate.Attempt){ "generator": runGenerator, "runner": runRunner, } worker := worker.Worker{ Namespace: namespace, Tasks: tasks, } worker.Run(context.Background()) }
func main() { backend := backend.Backend{Implementation: "memory"} app := cli.NewApp() app.Usage = "benchmark the Coordinate job queue system" app.Flags = []cli.Flag{ cli.GenericFlag{ Name: "backend", Value: &backend, Usage: "impl:[address] of Coordinate backend", }, cli.StringFlag{ Name: "namespace", Usage: "Coordinate namespace name", }, cli.IntFlag{ Name: "concurrency", Value: runtime.NumCPU(), Usage: "run this many jobs in parallel", }, } app.Commands = []cli.Command{ addUnits, doWork, clear, } app.Before = func(c *cli.Context) (err error) { bench.Coordinate, err = backend.Coordinate() if err != nil { return } bench.Namespace, err = bench.Coordinate.Namespace(c.String("namespace")) if err != nil { return } bench.WorkSpec, err = bench.Namespace.SetWorkSpec(map[string]interface{}{ "name": "spec", }) if err != nil { return } bench.Concurrency = c.Int("concurrency") return } app.RunAndExitOnError() }
func main() { var err error cborRPCBind := flag.String("cborrpc", ":5932", "[ip]:port for CBOR-RPC interface") httpBind := flag.String("http", ":5980", "[ip]:port for HTTP REST interface") backend := backend.Backend{Implementation: "memory", Address: ""} flag.Var(&backend, "backend", "impl[:address] of the storage backend") config := flag.String("config", "", "global configuration YAML file") logRequests := flag.Bool("log-requests", false, "log all requests") flag.Parse() var gConfig map[string]interface{} if *config != "" { gConfig, err = loadConfigYaml(*config) if err != nil { logrus.WithFields(logrus.Fields{ "err": err, }).Fatal("Could not load YAML configuration") return } } coordinate, err := backend.Coordinate() if err != nil { logrus.WithFields(logrus.Fields{ "err": err, }).Fatal("Could not create Coordinate backend") return } coordinate = cache.New(coordinate) var reqLogger *logrus.Logger if *logRequests { stdlog := logrus.StandardLogger() reqLogger = &logrus.Logger{ Out: stdlog.Out, Formatter: stdlog.Formatter, Hooks: stdlog.Hooks, Level: logrus.DebugLevel, } } go ServeCBORRPC(coordinate, gConfig, "tcp", *cborRPCBind, reqLogger) go ServeHTTP(coordinate, *httpBind) select {} }