github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/outputs/drop_on.md (about)

     1  ---
     2  title: drop_on
     3  type: output
     4  status: stable
     5  categories: ["Utility"]
     6  ---
     7  
     8  <!--
     9       THIS FILE IS AUTOGENERATED!
    10  
    11       To make changes please edit the contents of:
    12       lib/output/drop_on.go
    13  -->
    14  
    15  import Tabs from '@theme/Tabs';
    16  import TabItem from '@theme/TabItem';
    17  
    18  
    19  Attempts to write messages to a child output and if the write fails for one of a list of configurable reasons the message is dropped instead of being reattempted.
    20  
    21  ```yaml
    22  # Config fields, showing default values
    23  output:
    24    label: ""
    25    drop_on:
    26      error: false
    27      back_pressure: ""
    28      output: {}
    29  ```
    30  
    31  Regular Benthos outputs will apply back pressure when downstream services aren't accessible, and Benthos retries (or nacks) all messages that fail to be delivered. However, in some circumstances, or for certain output types, we instead might want to relax these mechanisms, which is when this output becomes useful.
    32  
    33  ## Fields
    34  
    35  ### `error`
    36  
    37  Whether messages should be dropped when the child output returns an error. For example, this could be when an http_client output gets a 4XX response code.
    38  
    39  
    40  Type: `bool`  
    41  Default: `false`  
    42  
    43  ### `back_pressure`
    44  
    45  An optional duration string that determines the maximum length of time to wait for a given message to be accepted by the child output before the message should be dropped instead. The most common reason for an output to block is when waiting for a lost connection to be re-established. Once a message has been dropped due to back pressure all subsequent messages are dropped immediately until the output is ready to process them again. Note that if `error` is set to `false` and this field is specified then messages dropped due to back pressure will return an error response.
    46  
    47  
    48  Type: `string`  
    49  Default: `""`  
    50  
    51  ```yaml
    52  # Examples
    53  
    54  back_pressure: 30s
    55  
    56  back_pressure: 1m
    57  ```
    58  
    59  ### `output`
    60  
    61  A child output.
    62  
    63  
    64  Type: `output`  
    65  Default: `{}`  
    66  
    67  ## Examples
    68  
    69  <Tabs defaultValue="Dropping failed HTTP requests" values={[
    70  { label: 'Dropping failed HTTP requests', value: 'Dropping failed HTTP requests', },
    71  { label: 'Dropping from outputs that cannot connect', value: 'Dropping from outputs that cannot connect', },
    72  ]}>
    73  
    74  <TabItem value="Dropping failed HTTP requests">
    75  
    76  In this example we have a fan_out broker, where we guarantee delivery to our Kafka output, but drop messages if they fail our secondary HTTP client output.
    77  
    78  ```yaml
    79  output:
    80    broker:
    81      pattern: fan_out
    82      outputs:
    83        - kafka:
    84            addresses: [ foobar:6379 ]
    85            topic: foo
    86        - drop_on:
    87            error: true
    88            output:
    89              http_client:
    90                url: http://example.com/foo/messages
    91                verb: POST
    92  ```
    93  
    94  </TabItem>
    95  <TabItem value="Dropping from outputs that cannot connect">
    96  
    97  Most outputs that attempt to establish and long-lived connection will apply back-pressure when the connection is lost. The following example has a websocket output where if it takes longer than 10 seconds to establish a connection, or recover a lost one, pending messages are dropped.
    98  
    99  ```yaml
   100  output:
   101    drop_on:
   102      back_pressure: 10s
   103      output:
   104        websocket:
   105          url: ws://example.com/foo/messages
   106  ```
   107  
   108  </TabItem>
   109  </Tabs>
   110  
   111