func (a *RawAdapter) Stream(logstream chan *router.Message) { msg := gabs.New() for message := range logstream { buf := new(bytes.Buffer) err := a.tmpl.Execute(buf, message) if err != nil { log.Debug("raw:", err) return } if cn := utils.M1[message.Container.Name]; cn != "" { //logmsg := utils.SendMessage(cn, buf.String(), message.Container) //_, err = connection.Write([]byte(logmsg)) utils.SendMessage(cn, buf.String(), message.Container.ID, msg) _, err = connection.Write(append([]byte(msg.String()), '\n')) if err != nil { log.Error("raw:", err, reflect.TypeOf(a.conn).String()) /*if reflect.TypeOf(a.conn).String() != "*net.TCPConn"{ return }*/ } } } }
func (a *RawAdapter) Stream(logstream chan *router.Message) { msg := gabs.New() for message := range logstream { buf := new(bytes.Buffer) err := a.tmpl.Execute(buf, message) if err != nil { log.Error("raw:", err) return } if cn := utils.M1[message.Container.Name]; cn != "" { utils.SendMessage(cn, buf.String(), message.Container.ID, msg) //logmsg := utils.SendMessage(cn, buf.String(), message.Container) msg := &kafka.ProducerMessage{Topic: topic, Value: kafka.StringEncoder(msg.String())} partition, offset, err := a.producer.SendMessage(msg) _, _, _ = partition, offset, err } } }