github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/broker/adapter/transformer/transformer.go (about) 1 // Copyright (c) 2019-2022, R.I. Pienaar and the Choria Project contributors 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package transformer 6 7 import ( 8 "time" 9 10 "github.com/choria-io/go-choria/broker/adapter/ingest" 11 ) 12 13 type Msg struct { 14 Protocol string `json:"protocol"` 15 Data string `json:"data"` 16 Sender string `json:"sender"` 17 Time time.Time `json:"time"` 18 RequestID string `json:"requestid"` 19 } 20 21 func TransformToOutput(msg ingest.Adaptable, adapterName string) *Msg { 22 return &Msg{ 23 Protocol: "choria:adapters:" + adapterName + ":output:1", 24 Data: string(msg.Message()), 25 Sender: msg.SenderID(), 26 Time: msg.Time().UTC(), 27 RequestID: msg.RequestID(), 28 } 29 }