Пример #1
0
func (cmd *ConnectionHandler) runBase(c *kingpin.ParseContext) error {
	if cmd.showAddress {
		cli.PrintJSON(cli.HTTPGet("v1/connection/address"))
	} else if cmd.showDns {
		cli.PrintJSON(cli.HTTPGet("v1/connection/dns"))
	} else {
		cli.PrintJSON(cli.HTTPGet("v1/connection"))
	}
	return nil
}
Пример #2
0
func (cmd *TopicHandler) runProducerTest(c *kingpin.ParseContext) error {
	query := url.Values{}
	query.Set("operation", "producer-test")
	query.Set("messages", strconv.FormatInt(int64(cmd.produceMessageCount), 10))
	cli.PrintJSON(cli.HTTPPutQuery(fmt.Sprintf("v1/topics/%s", cmd.topic), query.Encode()))
	return nil
}
Пример #3
0
func handleSeedsCommand(app *kingpin.Application) {
	app.Command("seeds", "Retrieve seed node information").Action(
		func(c *kingpin.ParseContext) error {
			cli.PrintJSON(cli.HTTPGet("v1/seeds"))
			return nil
		})
}
Пример #4
0
func (cmd *TopicHandler) runCreate(c *kingpin.ParseContext) error {
	query := url.Values{}
	query.Set("name", cmd.topic)
	query.Set("partitions", strconv.FormatInt(int64(cmd.createPartitions), 10))
	query.Set("replication", strconv.FormatInt(int64(cmd.createReplication), 10))
	cli.PrintJSON(cli.HTTPPostQuery("v1/topics", query.Encode()))
	return nil
}
Пример #5
0
func (cmd *TopicHandler) runOffsets(c *kingpin.ParseContext) error {
	var timeVal int64
	var err error
	switch cmd.offsetsTime {
	case "first":
		timeVal = -2
	case "last":
		timeVal = -1
	default:
		timeVal, err = strconv.ParseInt(cmd.offsetsTime, 10, 64)
		if err != nil {
			log.Fatalf("Invalid value '%s' for --time (expected integer, 'first', or 'last'): %s",
				cmd.offsetsTime, err)
		}
	}

	query := url.Values{}
	query.Set("time", strconv.FormatInt(timeVal, 10))
	cli.PrintJSON(cli.HTTPGetQuery(fmt.Sprintf("v1/topics/%s/offsets", cmd.topic), query.Encode()))
	return nil
}
Пример #6
0
func (cmd *TopicHandler) runDescribe(c *kingpin.ParseContext) error {
	cli.PrintJSON(cli.HTTPGet(fmt.Sprintf("v1/topics/%s", cmd.topic)))
	return nil
}
Пример #7
0
func (cmd *BrokerHandler) runRestart(c *kingpin.ParseContext) error {
	cli.PrintJSON(cli.HTTPPut(fmt.Sprintf("v1/brokers/%s", cmd.broker)))
	return nil
}
Пример #8
0
func (cmd *BrokerHandler) runReplace(c *kingpin.ParseContext) error {
	query := url.Values{}
	query.Set("replace", "true")
	cli.PrintJSON(cli.HTTPPutQuery(fmt.Sprintf("v1/brokers/%s", cmd.broker), query.Encode()))
	return nil
}
Пример #9
0
func (cmd *BrokerHandler) runList(c *kingpin.ParseContext) error {
	cli.PrintJSON(cli.HTTPGet("v1/brokers"))
	return nil
}
Пример #10
0
func (cmd *TopicHandler) runUnderReplicatedPartitions(c *kingpin.ParseContext) error {
	cli.PrintJSON(cli.HTTPGet("v1/topics/under_replicated_partitions"))
	return nil
}
Пример #11
0
func (cmd *TopicHandler) runUnavailablePartitions(c *kingpin.ParseContext) error {
	cli.PrintJSON(cli.HTTPGet("v1/topics/unavailable_partitions"))
	return nil
}
Пример #12
0
func (cmd *TopicHandler) runList(c *kingpin.ParseContext) error {
	cli.PrintJSON(cli.HTTPGet("v1/topics"))
	return nil
}
Пример #13
0
func (cmd *NodeHandler) runStatus(c *kingpin.ParseContext) error {
	cli.PrintJSON(cli.HTTPGet(fmt.Sprintf("v1/nodes/node-%d/status", cmd.nodeId.val)))
	return nil
}
Пример #14
0
func (cmd *NodeHandler) runRestart(c *kingpin.ParseContext) error {
	query := url.Values{}
	query.Set("node", fmt.Sprintf("node-%d", cmd.nodeId.val))
	cli.PrintJSON(cli.HTTPPutQuery("v1/nodes/restart", query.Encode()))
	return nil
}
Пример #15
0
func (cmd *NodeHandler) runList(c *kingpin.ParseContext) error {
	cli.PrintJSON(cli.HTTPGet("v1/nodes/list"))
	return nil
}