Example #1
0
File: command.go Project: h12w/kpax
func (cmd *ProduceCommand) Exec(cl model.Cluster) error {
	pr := producer.New(cl)
	var msg []byte
	if cmd.Msg != "" {
		msg = []byte(cmd.Msg)
	}
	v := make(map[string]interface{})
	if err := json.Unmarshal(msg, &v); err != nil {
		return err
	}
	fmt.Printf("%#v\n", v)
	value, err := cmd.Format.marshal(v)
	if err != nil {
		return err
	}
	return pr.Produce(cmd.Topic, nil, value)
}
Example #2
0
File: sender.go Project: h12w/kpax
func NewSender(brokers []string) Sender {
	return &simpleSender{p: producer.New(cluster.New(broker.NewDefault, brokers))}
}