Beispiel #1
0
func (r *Reporter) connect() (err error) {
	if r.conn == nil {
		r.conn, err = net.DialTimeout("udp", r.options.Endpoint,
			r.options.ConnTimeout)
		logx.OnFatal(err)
		logx.Debugf("connected to datapoints endpoint %s", r.options.Endpoint)
	}
	return
}
Beispiel #2
0
func main() {
	fs := flags.New().SetVersion(Version)
	fs.UseEnv = false
	fs.Boot()

	logx.SetLevel(log_level)
	prog, err := program.ParseFiles(flag.Args()...)
	logx.OnFatal(err)

	opts := options.NewGenOptions(layer, pack, core)

	gen_root := gen.NewGenRoot(prog, opts)

	// make package dir
	err = os.MkdirAll(filepath.Join(out, pack), os.ModePerm)
	logx.OnFatal(err)

	// Write types
	res, err := gen_root.Out()
	logx.OnFatal(err)
	for filename, box_res := range res {
		target := filepath.Join(out, pack, filename)
		err = ioutil.WriteFile(target, box_res, os.ModePerm)
		logx.OnFatal(err)
		logx.Infof("==> %s", target)
	}

	// Write Fns
	//	fn_fname, fn_res, err := gen_root.PipeOut()
	//	logx.OnFatal(err)
	//	target := filepath.Join(out, pack, fn_fname)
	//	err = ioutil.WriteFile(target, fn_res, os.ModePerm)
	//	logx.Infof("==> %s", target)
	//
	//	// Write package
	//	pack_res, err := gen_root.PackageOut()
	//	logx.OnFatal(err)
	//	target = filepath.Join(out, pack, pack) + ".go"
	//	err = ioutil.WriteFile(target, pack_res, os.ModePerm)
	//	logx.OnFatal(err)
	//	logx.Infof("==> %s", target)
}
Beispiel #3
0
// Bit ref
func nodifyBitRef(ns []parsec.ParsecNode) parsec.ParsecNode {
	if ns == nil || len(ns) == 0 {
		return nil
	}
	res := syntax.Condition{
		Ref: ns[0].(string),
	}
	b, err := strconv.Atoi(ns[2].(*parsec.Terminal).Value)
	logx.OnFatal(err)
	res.Bit = b
	return res
}
Beispiel #4
0
func main() {
	flags.New().SetPrefix("WAVES").Boot()
	logx.SetLevel(log_level)

	ctx, cancel := context.WithCancel(context.Background())

	mach := machine.NewMachine(ctx, interval)
	go mach.Start()

	datapointReporter := datapoint.NewReporter(&datapointOptions, noop)

	u, err := url.Parse(annotationsEndpoint)
	logx.OnFatal(err)
	if token != "" {
		u.User = url.User(token)
	}
	annReporter := annotation.NewReporter(&annotation.ReporterOptions{u}, noop)

	dp := dockerprobe.NewDockerProbe(dockerEndpoint,
		makeDockerReporter(datapointReporter),
		report.NewMetaReporter(strings.Split(dockerAnnotationTags, ","),
			annReporter),
	)
	err = mach.Add(dp)
	logx.OnFatal(err)

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)
	<-sigChan
	logx.Info("bye")
	cancel()
}
Beispiel #5
0
func (r *Reporter) Drop(rep *report.Report) (err error) {
	if !r.noop {
		v := url.Values{
			"title":       {rep.Key()},
			"description": {rep.Value()},
			"start_time":  {fmt.Sprintf("%d", rep.When().Unix())},
			"tag":         rep.Meta(),
		}
		res, err := r.cli.PostForm(r.endpoint, v)
		logx.OnFatal(err)
		bd, _ := ioutil.ReadAll(res.Body)
		bds := string(bd[:len(bd)])
		res.Body.Close()
		if bds != "" {
			logx.Fatal(bds)
		}
		logx.Infof("annotation sent: %+v", rep)
	} else {
		logx.Infof("annotation: %+v", rep)
	}
	return
}
Beispiel #6
0
func main() {
	logx.OnFatal(command.Run(os.Args[1:], os.Stdin, os.Stdout, os.Stderr))
}
Beispiel #7
0
	// Infinite multi box. Returns type wrapper with
	// -1 as multi
	twInfiniteMulti = parsec.And(func(ns []parsec.ParsecNode) parsec.ParsecNode {
		w := ns[1].(paramTypeW)
		w.multi = -1
		return w
	},
		basic.BracketL,
		twSimple,
		basic.BracketR,
	)

	// Multi with init
	twMulti = parsec.And(func(ns []parsec.ParsecNode) parsec.ParsecNode {
		n, err := strconv.Atoi(ns[0].(*parsec.Terminal).Value)
		logx.OnFatal(err)
		w := ns[2].(paramTypeW)
		w.multi = n
		return w
	},
		parsec.Int(),
		basic.Multi,
		twInfiniteMulti,
	)

	twBase = parsec.OrdChoice(basic.OneN,
		twMulti,
		twInfiniteMulti,
		twSimple,
	)