コード例 #1
0
ファイル: cli.go プロジェクト: elodina/syslog-service
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(&syslog.Config.ProducerProperties, "producer.properties", "", "Producer.properties file name.")
	flag.StringVar(&syslog.Config.BrokerList, "broker.list", "", "Kafka broker list separated by comma.")
	flag.StringVar(&syslog.Config.Topic, "topic", "", "Topic to produce data to.")
	flag.StringVar(&syslog.Config.TcpPort, "tcp.port", "", "TCP port range to accept.")
	flag.StringVar(&syslog.Config.UdpPort, "udp.port", "", "UDP port range to accept.")
	flag.StringVar(&syslog.Config.Transform, "transform", "", "Transofmation to apply to each message. none|avro")
	flag.StringVar(&syslog.Config.SchemaRegistryUrl, "schema.registry.url", "", "Avro Schema Registry url for transform=avro")
	flag.IntVar(&syslog.Config.NumProducers, "num.producers", math.MinInt64, "Number of producers to launch.")
	flag.IntVar(&syslog.Config.ChannelSize, "channel.size", math.MinInt64, "Producer buffer size.")

	flag.Parse()

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

	request := syslog.NewApiRequest(syslog.Config.Api + "/api/update")
	request.PutString("producer.properties", syslog.Config.ProducerProperties)
	request.PutString("broker.list", syslog.Config.BrokerList)
	request.PutString("topic", syslog.Config.Topic)
	request.PutString("tcp.port", syslog.Config.TcpPort)
	request.PutString("udp.port", syslog.Config.UdpPort)
	request.PutString("transform", syslog.Config.Transform)
	request.PutString("schema.registry.url", syslog.Config.SchemaRegistryUrl)
	request.PutInt("num.producers", int64(syslog.Config.NumProducers))
	request.PutInt("channel.size", int64(syslog.Config.ChannelSize))
	response := request.Get()

	fmt.Println(response.Message)

	return nil
}
コード例 #2
0
ファイル: cli.go プロジェクト: elodina/syslog-service
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 := syslog.NewApiRequest(syslog.Config.Api + "/api/status").Get()
	fmt.Println(response.Message)
	return nil
}
コード例 #3
0
ファイル: cli.go プロジェクト: elodina/syslog-service
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 := syslog.NewApiRequest(syslog.Config.Api + "/api/" + apiMethod)
	response := request.Get()

	fmt.Println(response.Message)

	return nil
}