Esempio n. 1
0
File: cli.go Progetto: ruo91/syscol
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(&syscol.Config.ProducerProperties, "producer.properties", "", "Producer.properties file name.")
	flag.StringVar(&syscol.Config.Topic, "topic", "", "Topic to produce data to.")
	flag.StringVar(&syscol.Config.Transform, "transform", "", "Transofmation to apply to each metric. none|avro")
	flag.StringVar(&syscol.Config.SchemaRegistryUrl, "schema.registry.url", "", "Avro Schema Registry url for transform=avro")

	flag.Parse()

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

	request := syscol.NewApiRequest(syscol.Config.Api + "/api/update")
	request.AddParam("producer.properties", syscol.Config.ProducerProperties)
	request.AddParam("topic", syscol.Config.Topic)
	request.AddParam("transform", syscol.Config.Transform)
	request.AddParam("schema.registry.url", syscol.Config.SchemaRegistryUrl)
	response := request.Get()

	fmt.Println(response.Message)

	return nil
}
Esempio n. 2
0
File: cli.go Progetto: ruo91/syscol
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 := syscol.NewApiRequest(syscol.Config.Api + "/api/status").Get()
	fmt.Println(response.Message)
	return nil
}
Esempio n. 3
0
File: cli.go Progetto: ruo91/syscol
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 := syscol.NewApiRequest(syscol.Config.Api + "/api/" + apiMethod)
	response := request.Get()

	fmt.Println(response.Message)

	return nil
}