Beispiel #1
0
func handleUpdate() error {
	var api string
	flag.StringVar(&api, "api", "", "Binding host:port for http/artifact server. Optional if SM_API env is set.")
	flag.StringVar(&statsd.Config.ProducerProperties, "producer.properties", "", "Producer.properties file name.")
	flag.StringVar(&statsd.Config.BrokerList, "broker.list", "", "Kafka broker list separated by comma.")
	flag.StringVar(&statsd.Config.Topic, "topic", "", "Topic to produce data to.")
	flag.StringVar(&statsd.Config.Transform, "transform", "", "Transofmation to apply to each metric. none|avro|proto")
	flag.StringVar(&statsd.Config.SchemaRegistryUrl, "schema.registry.url", "", "Avro Schema Registry url for transform=avro")
	flag.Float64Var(&statsd.Config.Cpus, "cpu", 0.1, "CPUs per task")
	flag.Float64Var(&statsd.Config.Mem, "mem", 64, "Mem per task")

	flag.Parse()

	if err := resolveApi(api); err != nil {
		return err
	}

	request := statsd.NewApiRequest(statsd.Config.Api + "/api/update")
	request.AddParam("producer.properties", statsd.Config.ProducerProperties)
	request.AddParam("broker.list", statsd.Config.BrokerList)
	request.AddParam("topic", statsd.Config.Topic)
	request.AddParam("transform", statsd.Config.Transform)
	request.AddParam("schema.registry.url", statsd.Config.SchemaRegistryUrl)
	request.AddParam("cpu", strconv.FormatFloat(statsd.Config.Cpus, 'E', -1, 64))
	request.AddParam("mem", strconv.FormatFloat(statsd.Config.Mem, 'E', -1, 64))
	response := request.Get()

	fmt.Println(response.Message)

	return nil
}
Beispiel #2
0
func handleStatus() error {
	var api string
	flag.StringVar(&api, "api", "", "Binding host:port for http/artifact server. Optional if SM_API env is set.")

	flag.Parse()
	if err := resolveApi(api); err != nil {
		return err
	}
	response := statsd.NewApiRequest(statsd.Config.Api + "/api/status").Get()
	fmt.Println(response.Message)
	return nil
}
Beispiel #3
0
func handleStartStop(start bool) error {
	var api string
	flag.StringVar(&api, "api", "", "Binding host:port for http/artifact server. Optional if SM_API env is set.")

	flag.Parse()

	if err := resolveApi(api); err != nil {
		return err
	}

	apiMethod := "start"
	if !start {
		apiMethod = "stop"
	}

	request := statsd.NewApiRequest(statsd.Config.Api + "/api/" + apiMethod)
	response := request.Get()

	fmt.Println(response.Message)

	return nil
}