Skip to content

Commit 0a49142

Browse files
authored
Merge pull request #600 from zmstone/delete-brod-cli
refactor: delete brod_cli code
2 parents 494a0cc + 246361f commit 0a49142

13 files changed

+5
-2323
lines changed

.github/workflows/build.yml

-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ jobs:
6363
rebar3-version: ${{ env.REBAR_VERSION }}
6464
- name: Compile
6565
run: rebar3 do compile
66-
- name: Make brod_cli script
67-
run: rebar3 as brod_cli escriptize
6866
- name: Run tests
6967
run: |
7068
export KAFKA_VERSION=${{ matrix.kafka }}

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
- 4.3.0
4+
- Split brod-cli out to a separate project [kafka4beam/brod-cli](https://github.com/kafka4beam/brod-cli)
5+
36
- 4.2.0
47
- Optimize consumer fetch latency.
58
Introduced the `share_leader_conn` consumer configuration option (default: `false`).

Makefile

-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ hex-publish: clean
3535
## tests that require kafka running at localhost
3636
INTEGRATION_CTS = brod_cg_commits brod_client brod_compression brod_consumer brod_producer brod_group_subscriber brod_topic_subscriber brod
3737

38-
## build escript and a release, and copy escript to release bin dir
39-
brod-cli:
40-
@rebar3 as brod_cli do compile,escriptize,release
41-
@cp _build/brod_cli/bin/brod_cli _build/brod_cli/rel/brod/bin/
42-
@cp scripts/brod _build/brod_cli/rel/brod/bin/
43-
@cp scripts/brod.escript _build/brod_cli/rel/brod/bin/
44-
4538
cover:
4639
@rebar3 cover -v
4740

README.md

-99
Original file line numberDiff line numberDiff line change
@@ -490,102 +490,3 @@ brod:delete_topics(Hosts, [Topic], Timeout).
490490
```
491491

492492
Caution the above delete_topics can fail if you do not have `delete.topic.enable` set to true in your kafka config
493-
494-
## brod-cli: A command line tool to interact with Kafka
495-
496-
This will build a self-contained binary with brod application
497-
498-
```bash
499-
make brod-cli
500-
_build/brod_cli/rel/brod/bin/brod -h
501-
```
502-
503-
Disclaimer: This script is NOT designed for use cases where fault-tolerance is a hard requirement.
504-
As it may crash when e.g. kafka cluster is temporarily unreachable,
505-
or (for fetch command) when the partition leader migrates to another broker in the cluster.
506-
507-
### brod-cli examples (with `alias brod=_build/brod_cli/rel/brod/bin/brod`):
508-
509-
#### Fetch and print metadata
510-
511-
```sh
512-
brod meta -b localhost
513-
```
514-
515-
#### Produce a Message
516-
517-
```sh
518-
brod send -b localhost -t test-topic -p 0 -k "key" -v "value"
519-
520-
```
521-
522-
#### Fetch a Message
523-
524-
```sh
525-
brod fetch -b localhost -t test-topic -p 0 --fmt 'io:format("offset=~p, ts=~p, key=~s, value=~s\n", [Offset, Ts, Key, Value])'
526-
```
527-
528-
Bound variables to be used in `--fmt` expression:
529-
530-
- `Offset`: Message offset
531-
- `Key`: Kafka key
532-
- `Value`: Kafka Value
533-
- `TsType`: Timestamp type either `create` or `append`
534-
- `Ts`: Timestamp, `-1` as no value
535-
536-
#### Stream Messages to Kafka
537-
538-
Send `README.md` to kafka one line per kafka message
539-
540-
```sh
541-
brod pipe -b localhost:9092 -t test-topic -p 0 -s @./README.md
542-
```
543-
544-
#### Resolve Offset
545-
546-
```sh
547-
brod offset -b localhost:9092 -t test-topic -p 0
548-
```
549-
550-
#### List or Describe Groups
551-
552-
```sh
553-
# List all groups
554-
brod groups -b localhost:9092
555-
556-
# Describe groups
557-
brod groups -b localhost:9092 --ids group-1,group-2
558-
```
559-
560-
#### Display Committed Offsets
561-
562-
```sh
563-
# all topics
564-
brod commits -b localhost:9092 --id the-group-id --describe
565-
566-
# a specific topic
567-
brod commits -b localhost:9092 --id the-group-id --describe --topic topic-name
568-
```
569-
570-
#### Commit Offsets
571-
572-
NOTE: This feature is designed for force overwriting commits, not for regular use of offset commit.
573-
574-
```sh
575-
# Commit 'latest' offsets of all partitions with 2 days retention
576-
brod commits -b localhost:9092 --id the-group-id --topic topic-name --offsets latest --retention 2d
577-
578-
# Commit offset=100 for partition 0 and 200 for partition 1
579-
brod commits -b localhost:9092 --id the-group-id --topic topic-name --offsets "0:100,1:200"
580-
581-
# Use --retention 0 to delete commits (may linger in kafka before cleaner does its job)
582-
brod commits -b localhost:9092 --id the-group-id --topic topic-name --offsets latest --retention 0
583-
584-
# Try join an active consumer group using 'range' protocol and steal one partition assignment then commit offset=10000
585-
brod commits -b localhost:9092 -i the-group-id -t topic-name -o "0:10000" --protocol range
586-
```
587-
588-
### TODOs
589-
590-
- Support scram-sasl in brod-cli
591-
- Transactional produce APIs

elvis.config

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
#{ level => 3,
3131
ignore => [ brod_group_coordinator
3232
, brod_utils
33-
, brod_cli
34-
, brod_cli_pipe
3533
]
3634
}}
3735
, {elvis_style, god_modules,

rebar.config

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
{deps, [{kafka_protocol, "4.1.9"}]}.
22
{project_plugins, [{rebar3_lint, "~> 3.2.5"}]}.
3-
{edoc_opts, [{preprocess, true}, {macros, [{build_brod_cli, true}]}]}.
3+
{edoc_opts, [{preprocess, true}]}.
44
{erl_opts, [warnings_as_errors, warn_unused_vars,warn_shadow_vars,warn_obsolete_guard,debug_info]}.
55
{xref_checks, [undefined_function_calls, undefined_functions,
66
locals_not_used, deprecated_function_calls,
77
deprecated_functions]}.
88
{profiles, [
9-
{brod_cli, [
10-
{deps, [ {docopt, {git, "https://github.com/zmstone/docopt-erl.git", {tag, "0.1.3"}}}
11-
, {jsone, "1.7.0"}
12-
, {snappyer, "1.2.9"}
13-
]},
14-
{erl_opts, [warnings_as_errors, {d, build_brod_cli}]},
15-
{escript_name, brod_cli},
16-
{relx, [{release, {brod, "i"}, % release the interactive shell as brod-i
17-
[brod, jsone, docopt]},
18-
{include_erts, true},
19-
{overlay, [{copy, "scripts/brod", "bin/"},
20-
{copy, "{{lib_dirs}}/crc32cer/priv/crc32cer*.so", "bin/"},
21-
{copy, "{{lib_dirs}}/snappyer/priv/snappyer.so", "bin/"}
22-
]}
23-
]}]},
249
{test, [
2510
{deps, [ {docopt, {git, "https://github.com/zmstone/docopt-erl.git", {tag, "0.1.3"}}}
2611
, {hut, "1.3.0"}

scripts/brod

-32
This file was deleted.

scripts/brod.escript

-31
This file was deleted.

src/brod.erl

+1-9
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
, delete_topics/4
101101
]).
102102

103-
%% APIs for quick metadata or message inspection and brod_cli
103+
%% APIs for quick metadata or message inspection
104104
-export([ get_metadata/1
105105
, get_metadata/2
106106
, get_metadata/3
@@ -128,10 +128,6 @@
128128
, fetch/8
129129
]).
130130

131-
-ifdef(build_brod_cli).
132-
-export([main/1]).
133-
-endif.
134-
135131
-export_type([ batch_input/0
136132
, bootstrap/0
137133
, call_ref/0
@@ -1365,10 +1361,6 @@ fetch_committed_offsets(BootstrapEndpoints, ConnCfg, GroupId) ->
13651361
fetch_committed_offsets(Client, GroupId) ->
13661362
brod_utils:fetch_committed_offsets(Client, GroupId, []).
13671363

1368-
-ifdef(build_brod_cli).
1369-
main(X) -> brod_cli:main(X).
1370-
-endif.
1371-
13721364
%% @doc Start a new transaction, `TxId' will be the id of the transaction
13731365
%% @equiv brod_transaction:start_link/3
13741366
-spec transaction(client(), transactional_id(), transaction_config()) -> {ok, transaction()}.

0 commit comments

Comments
 (0)