func WriteGaugeMessage(message *gauge_messages.Message, conn net.Conn) error { messageId := common.GetUniqueID() message.MessageId = &messageId data, err := proto.Marshal(message) if err != nil { return err } return Write(conn, data) }
func (p *plugin) sendMessage(message *gauge_messages.Message) error { messageID := common.GetUniqueID() message.MessageId = &messageID messageBytes, err := proto.Marshal(message) if err != nil { return err } err = conn.Write(p.connection, messageBytes) if err != nil { return fmt.Errorf("[Warning] Failed to send message to plugin: %s %s", p.descriptor.ID, err.Error()) } return nil }
func (plugin *plugin) sendMessage(message *gauge_messages.Message) error { messageId := common.GetUniqueId() message.MessageId = &messageId messageBytes, err := proto.Marshal(message) if err != nil { return err } err = conn.Write(plugin.connection, messageBytes) if err != nil { return errors.New(fmt.Sprintf("[Warning] Failed to send message to plugin: %d %s", plugin.descriptor.Id, err.Error())) } return nil }
func GetResponseForGaugeMessage(message *gauge_messages.Message, conn net.Conn) (*gauge_messages.Message, error) { messageId := common.GetUniqueID() message.MessageId = &messageId data, err := proto.Marshal(message) if err != nil { return nil, err } responseBytes, err := WriteDataAndGetResponse(conn, data) if err != nil { return nil, err } responseMessage := &gauge_messages.Message{} if err := proto.Unmarshal(responseBytes, responseMessage); err != nil { return nil, err } if err := checkUnsupportedResponseMessage(responseMessage); err != nil { return responseMessage, err } return responseMessage, err }
func checkUnsupportedResponseMessage(message *gauge_messages.Message) error { if message.GetMessageType() == gauge_messages.Message_UnsupportedMessageResponse { return fmt.Errorf("Unsupported Message response received. Message not supported. %s", message.GetUnsupportedMessageResponse().GetMessage()) } return nil }