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) }
func NewSender(brokers []string) Sender { return &simpleSender{p: producer.New(cluster.New(broker.NewDefault, brokers))} }