benthos

module
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2018 License: MIT

README

Benthos

godoc for Jeffail/benthos goreportcard for Jeffail/benthos Build Status

Benthos is a service that bridges message queues in ways that can simplify your platform and reduce development time. It also offers a variety of configurable message processors that can be chained together for solving common streaming problems such as content based multiplexing, filtering, modifying, batching, splitting, (de)compressing, (un)archiving, etc.

A range of optional buffer strategies are available, allowing you to select a balance between latency, protection against back pressure and file based persistence, or nothing at all (direct bridge).

Benthos is a single binary with zero dependencies, and uses a configuration file written in either YAML or JSON, making it quick and easy to package and deploy.

Supported Protocols

Arch Diagram

Currently supported input/output targets:

Setting up multiple outputs or inputs is done by choosing a routing strategy (fan-in, fan-out, round-robin, etc.)

It is possible to enable a REST API to dynamically change inputs and outputs at runtime, which you can read about here.

For a full and up to date list of all inputs, buffer options, processors, and outputs you can find them in the docs, or print them from the binary:

# Print inputs, buffers and output options
benthos --list-inputs --list-buffers --list-outputs --list-processors | less

Mixing multiple part message protocols with single part can be done in different ways, for more guidance check out this doc.

Install

Build with Go:

go get github.com/Jeffail/benthos/cmd/benthos

Or, pull the docker image:

docker pull jeffail/benthos

Or, download from here.

Run

benthos -c ./config.yaml

Or, with docker:

# Send HTTP /POST data to Kafka:
docker run --rm \
	-e "BENTHOS_INPUT=http_server" \
	-e "BENTHOS_OUTPUT=kafka" \
	-e "KAFKA_OUTPUT_BROKER_ADDRESSES=kafka-server:9092" \
	-e "KAFKA_OUTPUT_TOPIC=benthos_topic" \
	-p 4195:4195 \
	jeffail/benthos

# Using your own config file:
docker run --rm -v /path/to/your/config.yaml:/benthos.yaml jeffail/benthos

Config

Benthos has inputs, optional processors, an optional buffer, and outputs, which are all set in a single config file.

Check out the samples in ./config, or create a fully populated default configuration file:

benthos --print-yaml > config.yaml
benthos --print-json | jq '.' > config.json

If we wanted to pipe Stdin to a ZMQ push socket our YAML config might look like this:

input:
  type: stdin
output:
  type: zmq4
  zmq4:
    addresses:
      - tcp://*:1234
    socket_type: PUSH

There are also configuration sections for logging and metrics, if you print an example config you will see the available options.

For a list of metrics within Benthos check out this spec.

Environment Variables

You can use environment variables to replace fields in your config files.

ZMQ4 Support

Benthos supports ZMQ4 for both data input and output. To add this you need to install libzmq4 and use the compile time flag when building Benthos:

go install -tags "ZMQ4" ./cmd/...

Vendoring

Benthos uses dep for managing dependencies. To get started make sure you have dep installed:

go get -u github.com/golang/dep/cmd/dep

And then run dep ensure. You can decrease the size of vendor by only storing needed files with dep prune.

Docker

There's a multi-stage Dockerfile for creating a Benthos docker image which results in a minimal image from scratch. You can build it with:

make docker

Then use the image:

docker run --rm \
	-v /path/to/your/benthos.yaml:/config.yaml \
	-v /tmp/data:/data \
	-p 4195:4195 \
	benthos -c /config.yaml

There are a few examples here that show you some ways of setting up Benthos containers using docker-compose.

Directories

Path Synopsis
cmd
lib
api
Package api implements a type used for creating the Benthos HTTP API.
Package api implements a type used for creating the Benthos HTTP API.
broker
Package broker implements types used for routing inputs to outputs in non-trivial arrangements, such as fan-out or fan-in models.
Package broker implements types used for routing inputs to outputs in non-trivial arrangements, such as fan-out or fan-in models.
buffer
Package buffer links an input and an output together and buffers messages in between.
Package buffer links an input and an output together and buffers messages in between.
buffer/impl
Package impl contains implementations of various buffer types.
Package impl contains implementations of various buffer types.
input
Package input defines consumers for aggregating data from a variety of sources.
Package input defines consumers for aggregating data from a variety of sources.
input/reader
Package reader defines implementations of an interface for generic message reading from various third party sources.
Package reader defines implementations of an interface for generic message reading from various third party sources.
output
Package output defines dispatchers of data for a variety of targets.
Package output defines dispatchers of data for a variety of targets.
output/writer
Package writer defines implementations of an interface for generic message writing that outputs to various third party sinks.
Package writer defines implementations of an interface for generic message writing that outputs to various third party sinks.
pipeline
Package pipeline contains structures that implement both the Producer and Consumer interfaces.
Package pipeline contains structures that implement both the Producer and Consumer interfaces.
processor
Package processor contains logical message processors that can be pipelined within benthos using the pipeline.Processor type.
Package processor contains logical message processors that can be pipelined within benthos using the pipeline.Processor type.
processor/condition
Package condition contains logical operators that, based on their configuration, return boolean values from messages under certain circumstances.
Package condition contains logical operators that, based on their configuration, return boolean values from messages under certain circumstances.
types
Package types defines any general structs and interfaces used throughout the benthos code base.
Package types defines any general structs and interfaces used throughout the benthos code base.
util/disk
Package disk contains cross platform disk statistics utilities.
Package disk contains cross platform disk statistics utilities.
util/http/auth
Package auth provides configuration fields and implementations of HTTP request authentication strategies.
Package auth provides configuration fields and implementations of HTTP request authentication strategies.
util/service
Package service contains utilities for bootstrapping a server such as config, logging and metrics.
Package service contains utilities for bootstrapping a server such as config, logging and metrics.
util/service/config
Package config contains utilities for reading and parsing service configuration files.
Package config contains utilities for reading and parsing service configuration files.
util/service/log
Package log contains utilities for logging in a modular interface.
Package log contains utilities for logging in a modular interface.
util/service/metrics
Package metrics contains a type for aggregating and propagating metrics to various services based on configuration.
Package metrics contains a type for aggregating and propagating metrics to various services based on configuration.
util/test
Package test contains helpers for setting up test utilties.
Package test contains helpers for setting up test utilties.
util/text
Package text includes utilities for working with text that might contain variables.
Package text includes utilities for working with text that might contain variables.
util/throttle
Package throttle implements throttle strategies.
Package throttle implements throttle strategies.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL