2
2
3
3
## What is Bufstream?
4
4
5
- [ Bufstream] ( https://buf.build/product/bufstream ) is a drop-in replacement for
6
- Apache Kafka that's 10x cheaper to operate.
7
- While Bufstream works well for any Kafka workload, it excels when paired with
8
- Protobuf.
9
- By integrating with the Buf Schema Registry, Bufstream can enforce data quality
10
- and governance policies without relying on opt-in client configuration.
5
+ [ Bufstream] ( https://buf.build/product/bufstream ) is a drop-in replacement for Apache Kafka that's
6
+ 10x cheaper to operate. While Bufstream works well for any Kafka workload, it excels when paired
7
+ with Protobuf. By integrating with the Buf Schema Registry, Bufstream can enforce data quality and
8
+ governance policies without relying on opt-in client configuration.
11
9
12
- In this demonstration, you'll run a Bufstream agent locally, use the ` franz-go `
13
- library to publish and consume messages, and explore Bufstream's schema
14
- enforcement features.
10
+ In this demonstration, you'll run a Bufstream agent locally, use the
11
+ [ ` franz-go ` ] ( https://github.com/twmb/franz-go ) library to publish and consume messages, and explore
12
+ Bufstream's schema enforcement features.
15
13
16
14
## Requirements
17
15
18
16
- Git
19
- - [ Docker] ( https://docs.docker.com/engine/install/ )
17
+ - [ Docker] ( https://docs.docker.com/engine/install )
20
18
- [ Buf CLI] ( https://buf.build/docs/installation )
21
19
- [ Go 1.22+] ( https://go.dev/doc/install ) _ [ optional, for local development] _
22
20
23
21
## Getting started
24
22
25
- Before starting, perform the following steps to prepare your environment to run
26
- the demo.
23
+ Before starting, perform the following steps to prepare your environment to run the demo.
27
24
28
25
1 . Clone this repo:
29
26
30
27
``` shellsession
31
28
$ git clone https://github.com/bufbuild/bufstream-demo.git
32
- $ cd bufstream-demo
33
- ```
34
-
35
- 1 . Start downloading Docker images: _ [ optional] _
36
-
37
- ``` shellsession
38
- $ docker compose pull
29
+ $ cd ./bufstream-demo
39
30
```
40
31
41
32
## Try out Bufstream
42
33
43
- The Bufstream demo application simulates a small application that produces and
44
- consumes ` EmailUpdated ` event messages. The demo publishes these events to a
45
- Bufstream topic, followed by a separate consumer that fetches from the same
46
- topic and "verifies" the change. The demo app uses an off-the-shelf Kafka client
47
- ([ ` franz-go ` ] ( https://github.com/twmb/franz-go ) ) to interact with Bufstream.
34
+ The Bufstream demo application simulates two small applications that produce and consume
35
+ [ ` EmailUpdated ` ] ( proto/bufstream/demo/v1/demo.proto ) event messages. The demo
36
+ [ producer] ( cmd/bufstream-demo-produce/main.go ) publishes these events to a Bufstream topic, followed
37
+ by a separate [ consumer] ( cmd/bufstream-demo-consume/main.go ) that fetches from the same topic and
38
+ "verifies" the change. The demo app uses the off-the-shelf Kafka client
39
+ [ ` franz-go ` ] ( https://github.com/twmb/franz-go ) to interact with Bufstream.
48
40
49
41
The demo attempts to publish and consume three payloads:
50
42
51
43
- A semantically valid, correctly formatted version of the ` EmailUpdated ` message.
52
44
- A correctly formatted, but semantically invalid version of the message.
53
45
- A malformed message.
54
46
47
+ Some relevant sections to check out:
48
+
49
+ - [ cmd/bufstream-demo-produce] ( cmd/bufstream-demo-produce ) : The demo producer application.
50
+ - [ cmd/bufstream-demo-consume] ( cmd/bufstream-demo-consume ) : The demo consumer application.
51
+ - [ proto/bufstream/demo/v1/demo.proto] ( proto/bufstream/demo/v1/demo.proto ) : Defines the
52
+ ` EmailUpdated ` message type, which is produced and consumed from the ` email-updated ` topic.
53
+ - [ pkg] ( pkg ) : Contains helper packages for both the producer and consumer.
54
+
55
55
### Replace Apache Kafka
56
56
57
57
1 . Boot up the Bufstream and demo apps:
@@ -60,55 +60,52 @@ The demo attempts to publish and consume three payloads:
60
60
$ docker compose up --build
61
61
```
62
62
63
- 1 . The app logs both the publishing of the events on the producer side and
64
- shortly after, the consumption of these events. The consumer deserializes
65
- the first two messages correctly, while the final message fails with a
66
- deserialization error.
63
+ 1 . The app logs both the publishing of the events on the producer side and shortly after, the
64
+ consumption of these events. The consumer deserializes the first two messages correctly, while
65
+ the final message fails with a deserialization error.
67
66
68
67
At this point, you've used Bufstream as a drop-in replacement for Apache Kafka.
69
68
70
69
### Data quality enforcement
71
70
72
- Thus far, Bufstream hasn't applied any quality enforcement on the data passing
73
- through it &mdash ; addresses can be invalid or malformed. To ensure the quality
74
- of data flowing through Bufstream, you can configure policies that require data
75
- to conform to a pre-determined schema, pass semantic validation, and even
76
- redact sensitive information on the fly.
71
+ Thus far, Bufstream hasn't applied any quality enforcement on the data passing through it &mdash ;
72
+ addresses can be invalid or malformed. To ensure the quality of data flowing through Bufstream, you
73
+ can configure policies that require data to conform to a pre-determined schema, pass semantic
74
+ validation, and even redact sensitive information on the fly.
77
75
78
- We'll demonstrte this functionality using the Buf Schema Registry, but
79
- Bufstream also works with any registry that implements Confluent's REST API.
76
+ We'll demonstrate this functionality using the Buf Schema Registry, but Bufstream also works with
77
+ any registry that implements Confluent's REST API.
80
78
81
- 1 . Uncomment the ` data_enforcement ` block in [ ` configs /bufstream.yaml` ] ( configs /bufstream.yaml) .
79
+ 1 . Uncomment the ` data_enforcement ` block in [ ` config /bufstream.yaml` ] ( config /bufstream.yaml) .
82
80
83
- 1 . Uncomment the ` --csr ` command options under the ` demo ` service in [ ` docker-compose.yaml ` ] ( docker-compose.yaml ) .
81
+ 1 . Uncomment the ` --csr ` command options under the ` demo ` service in
82
+ [ ` docker-compose.yaml ` ] ( docker-compose.yaml ) .
84
83
85
- 1 . To pick up the configuration changes, terminate the Docker apps via ` ctrl+c ` and restart them with ` docker compose up ` .
84
+ 1 . To pick up the configuration changes, terminate the Docker apps via ` ctrl+c ` and restart them
85
+ with ` docker compose up ` .
86
86
87
- 1 . The app again logs both the attempted publishing and consumption of the
88
- three events. The first event will successfully reach the consumer. But
89
- with Bufstream's data quality enforcement enabled, the second and third
90
- messages are rejected.
87
+ 1 . The app again logs both the attempted publishing and consumption of the three events. The first
88
+ event will successfully reach the consumer. But with Bufstream's data quality enforcement
89
+ enabled, the second and third messages are rejected.
91
90
92
- 1 . For the message that reaches the consumer, notice the empty ` old_address ` in
93
- the logs. This field has been redacted by Bufstream as it's labeled with the
94
- ` debug_redact ` option.
91
+ 1 . For the message that reaches the consumer, notice the empty ` old_address ` in the logs. This field
92
+ has been redacted by Bufstream as it's labeled with the ` debug_redact ` option.
95
93
96
- By configuring Bufstream with a few data quality and governance policies,
97
- you've ensured that consumers receive only well-formed, semantically valid
98
- data.
94
+ By configuring Bufstream with a few data quality and governance policies, you've ensured that
95
+ consumers receive only well-formed, semantically valid data.
99
96
100
97
### Cleanup
101
98
102
- After completing the demo, you can stop Docker and remove credentials from your
103
- machine with the following commands:
99
+ After completing the demo, you can stop Docker and remove credentials from your machine with the
100
+ following commands:
104
101
105
102
```
106
103
docker compose down --rmi all
107
104
```
108
105
109
106
## Curious to see more?
110
107
111
- To learn more about Bufstream, check out the [ launch blog
112
- post] ( https://buf.build/blog/bufstream-kafka-lower-cost ) , dig into the
113
- [ benchmark and cost analysis] ( https://buf.build/docs/bufstream/cost ) , or [ join
114
- us in the Buf Slack] ( https://buf.build/links/slack ) !
108
+ To learn more about Bufstream, check out the
109
+ [ launch blog post] ( https://buf.build/blog/bufstream-kafka-lower-cost ) , dig into the
110
+ [ benchmark and cost analysis] ( https://buf.build/docs/bufstream/cost ) , or
111
+ [ join us in the Buf Slack] ( https://buf.build/links/slack ) !
0 commit comments