github.com/Jeffail/benthos/v3@v3.65.0/lib/output/sync_response.go (about) 1 package output 2 3 import ( 4 "github.com/Jeffail/benthos/v3/internal/docs" 5 "github.com/Jeffail/benthos/v3/lib/log" 6 "github.com/Jeffail/benthos/v3/lib/message/roundtrip" 7 "github.com/Jeffail/benthos/v3/lib/metrics" 8 "github.com/Jeffail/benthos/v3/lib/types" 9 ) 10 11 //------------------------------------------------------------------------------ 12 13 func init() { 14 Constructors[TypeSyncResponse] = TypeSpec{ 15 constructor: fromSimpleConstructor(func(_ Config, _ types.Manager, logger log.Modular, stats metrics.Type) (Type, error) { 16 return NewWriter(TypeSyncResponse, roundtrip.Writer{}, logger, stats) 17 }), 18 Summary: ` 19 Returns the final message payload back to the input origin of the message, where 20 it is dealt with according to that specific input type.`, 21 Description: ` 22 For most inputs this mechanism is ignored entirely, in which case the sync 23 response is dropped without penalty. It is therefore safe to use this output 24 even when combining input types that might not have support for sync responses. 25 An example of an input able to utilise this is the ` + "`http_server`" + `. 26 27 It is safe to combine this output with others using broker types. For example, 28 with the ` + "`http_server`" + ` input we could send the payload to a Kafka 29 topic and also send a modified payload back with: 30 31 ` + "```yaml" + ` 32 input: 33 http_server: 34 path: /post 35 output: 36 broker: 37 pattern: fan_out 38 outputs: 39 - kafka: 40 addresses: [ TODO:9092 ] 41 topic: foo_topic 42 - sync_response: {} 43 processors: 44 - bloblang: 'root = content().uppercase()' 45 ` + "```" + ` 46 47 Using the above example and posting the message 'hello world' to the endpoint 48 ` + "`/post`" + ` Benthos would send it unchanged to the topic 49 ` + "`foo_topic`" + ` and also respond with 'HELLO WORLD'. 50 51 For more information please read [Synchronous Responses](/docs/guides/sync_responses).`, 52 Categories: []Category{ 53 CategoryUtility, 54 }, 55 config: docs.FieldComponent().HasType(docs.FieldTypeObject), 56 } 57 } 58 59 //------------------------------------------------------------------------------