github.com/Jeffail/benthos/v3@v3.65.0/lib/input/zmq4.go (about)

     1  //go:build ZMQ4
     2  // +build ZMQ4
     3  
     4  package input
     5  
     6  import (
     7  	"github.com/Jeffail/benthos/v3/internal/docs"
     8  	"github.com/Jeffail/benthos/v3/lib/input/reader"
     9  	"github.com/Jeffail/benthos/v3/lib/log"
    10  	"github.com/Jeffail/benthos/v3/lib/metrics"
    11  	"github.com/Jeffail/benthos/v3/lib/types"
    12  )
    13  
    14  //------------------------------------------------------------------------------
    15  
    16  func init() {
    17  	Constructors[TypeZMQ4] = TypeSpec{
    18  		constructor: fromSimpleConstructor(NewZMQ4),
    19  		Summary: `
    20  Consumes messages from a ZeroMQ socket.`,
    21  		Description: `
    22  ZMQ4 is supported but currently depends on C bindings. Since this is an
    23  annoyance when building or using Benthos it is not compiled by default.
    24  
    25  There is a specific docker tag postfix ` + "`-cgo`" + ` for C builds containing
    26  ZMQ support.
    27  
    28  You can also build it into your project by getting libzmq installed on your
    29  machine, then build with the tag:
    30  
    31  ` + "```sh" + `
    32  go install -tags "ZMQ4" github.com/Jeffail/benthos/v3/cmd/benthos
    33  ` + "```" + `
    34  
    35  ZMQ4 input supports PULL and SUB sockets only. If there is demand for other
    36  socket types then they can be added easily.`,
    37  		FieldSpecs: docs.FieldSpecs{
    38  			docs.FieldString("urls", "A list of URLs to connect to. If an item of the list contains commas it will be expanded into multiple URLs.").Array(),
    39  			docs.FieldBool("bind", "Whether to bind to the specified URLs or connect."),
    40  			docs.FieldString("socket_type", "The socket type to connect as.").HasOptions("PULL", "SUB"),
    41  			docs.FieldString("sub_filters", "A list of subscription topic filters to use when consuming from a SUB socket. Specifying a single sub_filter of `''` will subscribe to everything.").Array(),
    42  			docs.FieldInt("high_water_mark", "The message high water mark to use.").Advanced(),
    43  			docs.FieldString("poll_timeout", "The poll timeout to use.").Advanced(),
    44  		},
    45  		Categories: []Category{
    46  			CategoryNetwork,
    47  		},
    48  	}
    49  }
    50  
    51  //------------------------------------------------------------------------------
    52  
    53  // NewZMQ4 creates a new ZMQ input type.
    54  func NewZMQ4(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error) {
    55  	z, err := reader.NewZMQ4(conf.ZMQ4, log, stats)
    56  	if err != nil {
    57  		return nil, err
    58  	}
    59  	return NewAsyncReader(TypeZMQ4, true, reader.NewAsyncPreserver(z), log, stats)
    60  }
    61  
    62  //------------------------------------------------------------------------------